w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » STRING » Page 1
HIVE STRING TO DATE CASTING
A combination of date functions in hive can be used to get this. select TO_DATE(from_unixtime(UNIX_TIMESTAMP('7-MAR-13', 'd-MMMM-yy'))) from table_name Output: 2013-03-07

Categories : String

Algorithm for fuzzy pairing of strings from two lists
OK, here's my python solution using the Levenshtein distance and the Hungarian algorithm (both provided by external packages): from munkres import Munkres from Levenshtein import distance from sys import argv if __name__ == '__main__': if len(argv) < 3: print("Usage: fuzzy_match.py file file") print("Finds the best pairing of lines from the two input files") print(

Categories : String

strlen pointer vs array
According to the strlen doc : The length of a C string is determined by the terminating null-character: A C string is as long as the number of characters between the beginning of the string and the terminating null character (without including the terminating null character itself). This should not be confused with the size of the array that holds the string. If pixels[i] equal 0, strle

Categories : String

Find string after "X" date
If the date portion of the string is always in the same location, you can simply use the string handling functions to parse it out. At that point, convert it to an integer if necessary, then compare the result with your target date.

Categories : String

Change UIDatePicker text color
According to Apple's UIKit User Interface Catalog, developers are not allowed to customise date pickers. It has been said already around... https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UIDatePicker.html#//apple_ref/doc/uid/TP40012857-UIDatePicker-SW3 Life's tough!

Categories : String

assembly 8086 adding a space in a string
There are a few problems with the code. The first one is this line: CMP dl+1, ' ' This is adding 1 to the value in dl and comparing that to a space character which is not what you want. What you want is to compare the next character, so you'll have to load it into a register with MOV dl, [si] or similar. The second problem is algorithm. It's often easiest to start with psuedo-code and t

Categories : String

Error in using indexOf not finding char in Arduino String
This: char phone = Serial.read(); String str = String(phone); will never create a string in str that has more than 1 character, since that's what you say you want. This is the code for the Arduino's String(char) constructor: String::String(char c) { init(); char buf[2]; buf[0] = c; buf[1] = 0; *this = buf; } So clearly your code will create a 1-character long string. Also, beware

Categories : String

Return a number and text string in Excel If statement
You are almost there. It should be : =IF((H11-J11)<0,abs(H11-J11) & " Days overdue",(abs(H11-TODAY())) & " Days Until Due") In fact you are just missing the string concatenation character &.

Categories : String

Remove whitespace character set from string excluding space
NSCharacterSet makes this easy: func condenseWhitespace(string: String) -> String { let components = string.componentsSeparatedByCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).filter({!isEmpty($0)}) return join(" ", components) } var string = " Lorem ipsum dolar sit amet. " println(condenseWhitespace(string)) // Lorem ipsum dolar sit amet. or if you'd li

Categories : String

clojure: remove a set of strings from a sentence
for iterates over the seq given to it, producing another sequence. So, you're generating a list with elements representing each replacement separately but not combined. What you want is first replacing the first word, then - on the result of that replacement - remove the second one, and so on. This is a typical case for reduce: (defn remove-words-from-sentence [sentence words] (reduce #(.rep

Categories : String

Swift search string for any number?
If you need to match any date in your string you can use NSDataDetector - NSRegularExpression subclass designed to detect some specific data: Swift version: var error : NSError? if let detector = NSDataDetector(types: NSTextCheckingType.Date.rawValue, error: &error) { let testString = "Today date is 15/11/2014!! Yesterday was 15-11-2014" let matches = detector.matchesInString(testStrin

Categories : String

List of Strings obtained by replacing each character in a String by all other alphabet characters
Let's assume that the argument of your function matches the pattern (x:xs); for the sake of brevity, I won't discuss the base case. Use a list comprehension to generate a list of Strings in which x is replaced by all other letters in your alphabet: [ c:xs | c <- alphabet, c /= x ] The generator draws a character c from the alphabet, but the predicate forbids c to be the same as x. Apply yo

Categories : String

How can I get the list of strings obtained by deleting one character from a given string?
What you are doing would (almost) work, but you are re-adding the value.... You do realize that delete x (x:theList) is just theList don't you? Basically, (x:theList) tells the computer to prepend x to theList, while delete x tells the computer to remove the first x from the list. This almost would work [delete c xs |c <- xs] but do keep in mind that delete only removes the first oc

Categories : String

categorizing string according to length in Python
You could use defaultdict: from collections import defaultdict words = ['this','that','is','am','are','i','j'] with_lengths = [(word, len(word)) for word in words] output = defaultdict(list) for k, v in with_lengths: output[v].append(k) for key in output: print '%i -> %s' % (key, output[key]) Output: 1 -> ['i', 'j'] 2 -> ['is', 'am'] 3 -> ['are'] 4 -> ['this', 'that']

Categories : String

Haskell transpose chars in String
f :: String -> [String] f (x:y:xs) = (y:x:xs) : map (x:) (f (y:xs)) f xs = [] Note, that f [x] returns [], but it's easy to fix, if this is desired.

Categories : String

Can we do it better than O(n^2)?
how about in a single loop that compares the ends of the strings and makes them match, moving towards the middle.. it will run in O(N)..in some cases, it won't be the absolute minimal amount of modification.. but if performance is the issue.. it may strike the correct balance.. String.prototype.insertAt=function(index, string) { return this.substr(0, index) + string + this.substr(index); } v

Categories : String

Algorithm to detect if a file(or string) have been patched
It's pretty complicated, but it can be done, on some level. Essentially, you parse the source level into tokens, after that, you build the abstract syntax tree. Once that is done, you must build a diff tool that can do semantic differential analysis between abstract syntax trees. SemanticMerge for example, does that. Once that is done, you have semantical difference between two source codes, and

Categories : String

Concatinate string literals using IntelliJ IDEA Structural Replace
It looks like Structural Search does not currently support your use case exactly. You can match your string using the query: "$String1$"+"$String2$"+"$String3$" and replace with: "$String1$$String2$$String3$" But this will only find string concatenations of three string literals. You may want to file a bug report at http://youtrack.jetbrains.com

Categories : String

Alphabet string code, looping
I accomplished it with a nested loop: Console.Write("Please, type in a word: "); string start = Console.ReadLine(); string alphabet = "abcdefghijklmnopqrstuvwxyz"; for (int a = 0; a < start.Length; a++) { for (int c = 0; c < alphabet.Length; c++) { if (start[a] == alphabet[c]) { Console.Write(c + 1); } } } While comparing the strings, it m

Categories : String

reading dates from xls to csv through Perl
The problematic line was $cellcon = $cell->unformatted(); Unless someone can offer a better explanation, I'll regard this as a bug. The line that I substituted was $cellcon = $cell->Value;

Categories : String

uUable to use the output of the command "SFC /scannow" in powershell
Out-File defaults to writing in Unicode. You can you change that with -Encoding ASCII. You can also use Set-Content which defaults to ASCII. You might also be able to tell Notepad++ to interpret the file as Unicode, but I'm not familiar with how to do that.

Categories : String

remove a substring from filename
You could list all the files with a same pattern *english.mp3 And you could trim strings with DOS commands, check this example @echo off SETLOCAL enabledelayedexpansion set oldname=ABCDEFG.english.mp3 echo. %oldname% set newname=!oldname:~0,-12! echo. %newname%.mp3 Then check this guide: DOS substring manipulation All you need to do is put inside your for loop a "move" or "ren" command wit

Categories : String

Get the last character of a String from a file in Python?
Make sure to call ofile.close() in the same scope as where you wrote ofile = open('some_file.txt', 'w'), but after your call to getListEnd of course. So you'll have your code looking like this: def getListEnd(c,ifile,ofile): for line in ifile: if c in line[-1]: ofile.write(str(line)) infile = open('inputfile.txt', 'r') outfile = open('outputfile.txt', 'w') getListEnd('$'

Categories : String

Perl: Find all matched substrings of two strings
Your example seems to show returning two different lengths of substring, with the shorter one first, so I'm not sure what "maximal by length" means. But this may help: use Tree::Suffix; my $string1 = '(i==i)kn;i=n.n;k(i(i,"%i",&i);i'; my $string2 = 'k;kn;i=n.n;k;k(i(i,"%i",&i);k'; my $tree = Tree::Suffix->new($string1, $string2); my @answer; my $min_length = 1; my $max_length = 0; # 0

Categories : String

Convert string slice to int in rust
The input includes a newline at the end, as explained in the documentation for read_line, and that causes from_str() to fail and return None. Using std::str::trim() and changing this: let input: Option<int> = from_str(input_text.as_slice()); into this: let input: Option<int> = from_str(input_text.trim().as_slice()); seems to work.

Categories : String

Go: Retrieve a string from between two characters or other strings
Read up on the strings package. Have a look into the SplitAfter function which can do something like this: var sample = "[this][is my][string]" t := strings.SplitAfter(sample, "[") That should produce a slice something like: "[", "this][", "is my][", "string]". Using further functions for Trimming you should get your solution. Best of luck.

Categories : String

The lifetime of &str makes comparison hard
& is a pointer, it points to a memory that somebody else owns. So, &str is a pointer to a string memory (slice) that somebody else owns. String, on the other hand, is a string that owns its memory and keeps the characters there. Now, when you generate a base64 you make something new, it's like hearing a piano concerto and catching it in an oil painting. Instead of taking your brush and ma

Categories : String

JPA Mapping enums to different String
Enjoy best practise here: Your entity @Entity public class MyEntity { @Column protected String status; public Status getStatus() { return Status.fromId(status); } public void setStatus(Status status) { this.status = status == null ? null : status.getId(); } } Code of Status enum public enum Status { OK("200"), NOT_OK("500"); protected String

Categories : String

After you input a string that contains a single * character, how can I replace that character with the second string I create in my code?
Looks like AP stands for assembly language programming. Assembly Language : Assume you have the replacement string. Algorithm : 1. count the number of characters in the second string 2. shift all the letters in the first string starting from * by n spaces to right. 3. point si to the * character in the first string and di to the second character in the second string. 4. go on copying character by

Categories : String

Expanding an alpha-numeric string in an Excel cell into comma separated individual alpha-numerics
Select cells that contain data like: C100-C110 and run this simple macro: Sub SpreadThem() Dim r As Range, N1 As Long, N2 As Long, i As Long Dim st As String, CH As String For Each r In Selection If InStr(r.Text, "-") > 0 Then ary = Split(r.Text, "-") N1 = Mid(ary(0), 2) N2 = Mid(ary(1), 2) CH = Left(ary(0), 1)

Categories : String

SPSS Looping across multiple string variables to find duplicates
I believe I solved the problem. COMPUTE index=$CASENUM. SORT CASES BY name1. STRING key (a63). COMPUTE main=name2. AGGREGATE OUTFILE * / BREAK name1 / found=N. RENAME VARIABLES name1=main. MATCH FILES FILE index / TABLE * /IN=match / BY main . SORT CASES BY index. Thanks for those that viewed and were thinking about the problem for me.

Categories : String

Access data on the stack
Yes, you can access items on the stack because stack is just memory. However if you are in 16 bit mode, you can not use DX for that, you need BX, SI, DI or BP. For example: mov bx, sp mov bl, ss:[bx+10] Note you need ss segment override for anything except BP. In 32 bit mode you can use ESP directly, such as: mov dl, [esp+10] PS: that's a fairly strange project for a first program ;)

Categories : String

extract string between two strings of a cut result
If you don't mind using sed: bash-3.2$ cut -f 14 myfile | sed 's/.*SYMBOL=([^;]*);.*/1/g' GLRA3 GLRA3 And using only cut with the -d option: bash-3.2$ cut -f 14 myfile | cut -d';' -f 2|cut -d'=' -f 2 GLRA3 GLRA3

Categories : String

perform operations next to a string in matlab
I think you are simply looking for the command str2num Here is one idea: input_data={"sell","50","FTSE","6500"; "buy","100","Eurostoxx","3300"; "buy","25","SP","1980", "buy","30","FTSE","6490", "sell","25","Eurostoxx","3315"}; closing_price.FTSE=6000; closing_price.Eurostoxx=3000; closing_price.SP=2000; for i=1:size(input_data,1) if strcmp(in

Categories : String

sed - search and replace between 2 marks
That shoudl do what you need: echo $string | sed -e 's/[a-zA-Z.]+Team([0-9]+)/B.Team1/g' It searches for alphabetic characters and also a dot (.) followed by the word Team, followed by a number ([0-9]). That all will be replaced by whatever you want. In the example it's B.Team followed by the found number (1).

Categories : String

string concatenation and apostrophe marks
If you need your sql_statement to finish like select [...] tableTwo.f2 ='Health' you need to add 2 more single quotes at the end of you strcat: sql_statement = strcat('select some_feilds from'... ,' databaseOne.tableOne'... ,' join databaseTwo.tableTwo'... ,' on databaseOne.tableOne.f1 = databaseTwo.tableTwo.f2'...

Categories : String

Failing string compare in Lua
s = s .. ifname .. "=" .. v.name .. '?' if iface == v.name then You are using iface in the comparison, not ifname. If a variable isn't given a value before, its value is nil, but no error is given as it's legal Lua.

Categories : String

Bash split a space-delimited string into a variable number of substrings
So, firstly — instead of space-delimited strings, you should probably use arrays: permitted_hosts=(node1 node2 node3) runs_list=(run1 run2 run3 run4 run5) If you have to start out with space-delimited strings, you can at least convert them to arrays: permitted_hosts=($permitted_hosts_str) runs_list=($runs_list_str) That out of the way . . . basically you have two steps: (1) convert the

Categories : String

Haskell filtered string to list
At the risk of answering a homework question: import Data.Char toString :: String -> [String] toString str = filter (not . null) . map (map toLower . filter isAlpha) . words $ str Prelude Data.Char> toString "Hello I am 25 years old!" ["hello", "i", "am", "years", "old"]

Categories : String




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.