tokenize

Splitting comma separated string in a PL/SQL stored proc

江枫思渺然 提交于 2019-11-26 11:02:26
问题 I\'ve CSV string 100.01,200.02,300.03 which I need to pass to a PL/SQL stored procedure in Oracle. Inside the proc,I need to insert these values in a Number column in the table. For this, I got a working approach from over here: How to best split csv strings in oracle 9i [2) Using SQL\'s connect by level.]. Now,I\'ve another requirement. I need to pass 2 CSV strings[equal in length] as input to PL/SQL stored proc.And, I need to break this string and insert each value from two CSV strings into

How to split a string in shell and get the last field

好久不见. 提交于 2019-11-26 08:39:46
问题 Suppose I have the string 1:2:3:4:5 and I want to get its last field ( 5 in this case). How do I do that using Bash? I tried cut , but I don\'t know how to specify the last field with -f . 回答1: You can use string operators: $ foo=1:2:3:4:5 $ echo ${foo##*:} 5 This trims everything from the front until a ':', greedily. ${foo <-- from variable foo ## <-- greedy front trim * <-- matches anything : <-- until the last ':' } 回答2: Another way is to reverse before and after cut : $ echo ab:cd:ef |

Convert comma separated string to array in PL/SQL

余生颓废 提交于 2019-11-26 06:34:06
问题 How do I convert a comma separated string to a array? I have the input \' 1,2,3\' , and I need to convert it into an array. 回答1: Oracle provides the builtin function DBMS_UTILITY.COMMA_TO_TABLE. Unfortunately, this one doesn't work with numbers: SQL> declare 2 l_input varchar2(4000) := '1,2,3'; 3 l_count binary_integer; 4 l_array dbms_utility.lname_array; 5 begin 6 dbms_utility.comma_to_table 7 ( list => l_input 8 , tablen => l_count 9 , tab => l_array 10 ); 11 dbms_output.put_line(l_count);

How to get a Token from a Lucene TokenStream?

社会主义新天地 提交于 2019-11-26 06:18:20
问题 I\'m trying to use Apache Lucene for tokenizing, and I am baffled at the process to obtain Tokens from a TokenStream . The worst part is that I\'m looking at the comments in the JavaDocs that address my question. http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/analysis/TokenStream.html#incrementToken%28%29 Somehow, an AttributeSource is supposed to be used, rather than Token s. I\'m totally at a loss. Can anyone explain how to get token-like information from a TokenStream? 回答1:

NSString tokenize in Objective-C

久未见 提交于 2019-11-26 06:14:33
What is the best way to tokenize/split a NSString in Objective-C? Found this at http://borkware.com/quickies/one?topic=NSString (useful link): NSString *string = @"oop:ack:bork:greeble:ponies"; NSArray *chunks = [string componentsSeparatedByString: @":"]; Hope this helps! Adam Everyone has mentioned componentsSeparatedByString: but you can also use CFStringTokenizer (remember that an NSString and CFString are interchangeable) which will tokenize natural languages too (like Chinese/Japanese which don't split words on spaces). If you just want to split a string, use -[NSString

Tokenizing strings in C

陌路散爱 提交于 2019-11-26 05:58:31
问题 I have been trying to tokenize a string using SPACE as delimiter but it doesn\'t work. Does any one have suggestion on why it doesn\'t work? Edit: tokenizing using: strtok(string, \" \"); The code is like the following pch = strtok (str,\" \"); while (pch != NULL) { printf (\"%s\\n\",pch); pch = strtok (NULL, \" \"); } 回答1: Do it like this: char s[256]; strcpy(s, "one two three"); char* token = strtok(s, " "); while (token) { printf("token: %s\n", token); token = strtok(NULL, " "); } Note:

Nested strtok function problem in C [duplicate]

戏子无情 提交于 2019-11-26 03:59:46
问题 This question already has an answer here: Using strtok() in a loop in C? 3 answers I have a string like this: a;b;c;d;e f;g;h;i;j 1;2;3;4;5 and i want to parse it element by element. I used nested strtok function but it just splits first line and makes null the token pointer. How can i overcome this? Here is the code: token = strtok(str, \"\\n\"); while(token != NULL && *token != EOF) { char a[128], b[128]; strcpy(a,token); strcpy(b,a); printf(\"a:%s\\n\",a); char *token2 = strtok(a,\";\");

How do I read input character-by-character in Java?

好久不见. 提交于 2019-11-26 03:57:07
问题 I am used to the c-style getchar() , but it seems like there is nothing comparable for java. I am building a lexical analyzer, and I need to read in the input character by character. I know I can use the scanner to scan in a token or line and parse through the token char-by-char, but that seems unwieldy for strings spanning multiple lines. Is there a way to just get the next character from the input buffer in Java, or should I just plug away with the Scanner class? The input is a file, not

How to use stringstream to separate comma separated strings [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-11-26 03:47:49
问题 This question already has an answer here: How do I iterate over the words of a string? 76 answers I\'ve got the following code: std::string str = \"abc def,ghi\"; std::stringstream ss(str); string token; while (ss >> token) { printf(\"%s\\n\", token.c_str()); } The output is: abc def,ghi So the stringstream::>> operator can separate strings by space but not by comma. Is there anyway to modify the above code so that I can get the following result? input : \"abc,def,ghi\" output : abc def ghi

how to convert csv to table in oracle

拜拜、爱过 提交于 2019-11-26 02:58:47
问题 How can I make a package that returns results in table format when passed in csv values. select * from table(schema.mypackage.myfunction(\'one, two, three\')) should return one two three I tried something from ask tom but that only works with sql types. I am using oracle 11g. Is there something built-in? 回答1: The following works invoke it as select * from table(splitter('a,b,c,d')) create or replace function splitter(p_str in varchar2) return sys.odcivarchar2list is v_tab sys.odcivarchar2list