stringtokenizer

Read data from a text file and create an object

為{幸葍}努か 提交于 2019-11-30 07:45:11
I need some help: I'm making a Supermarket simulation on Java, but I've got one problem, I have a text file (Stock.txt) where I have all the supermarket stock on it for example: 0-Bakery-Chocolate Cake-$12.5-250 1-Meat-Premium Steak-$2.6-120 2-Seafood-Tuna - $1.2-14 ... Where the first number is the "id" for the product, next is the department the product belongs, third is the name of the product, the next thing is the price, and the last number is how much pieces of the product the stock has. I have this class: public class Product { protected String name; protected double price; protected

C# Tokenizer - keeping the separators [duplicate]

筅森魡賤 提交于 2019-11-30 07:33:34
This question already has an answer here: Does C# have a String Tokenizer like Java's? 11 answers I am working on porting code from JAVA to C#, and part of the JAVA code uses tokenizer - but it is my understanding that the resulting array from the stringtokenizer in Java will also have the separators (in this case +, -, /, *, (, )) as tokens. I have attempted to use the C# Split() function, but it seems to eliminate the separators themselves. In the end, this will parse a string and run it as a calculation. I have done a lot of research, and have not found any references on the topic. Does

Does PL/SQL have an equivalent StringTokenizer to Java's?

冷暖自知 提交于 2019-11-29 11:24:34
I use java.util.StringTokenizer for simple parsing of delimited strings in java. I have a need for the same type of mechanism in pl/sql. I could write it, but if it already exists, I would prefer to use that. Anyone know of a pl/sql implementation? Some useful alternative? PL/SQL does include a basic one for comma separated lists ( DBMS_UTILITY.COMMA_TO_TABLE ). Example: DECLARE lv_tab_length BINARY_INTEGER; lt_array DBMS_UTILITY.lname_array; BEGIN DBMS_UTILITY.COMMA_TO_TABLE( list => 'one,two,three,four' , tablen => lv_tab_length , tab => lt_array ); DBMS_OUTPUT.PUT_LINE( 'lv_tab_length = ['|

C# Tokenizer - keeping the separators [duplicate]

こ雲淡風輕ζ 提交于 2019-11-29 09:56:09
问题 This question already has answers here : Does C# have a String Tokenizer like Java's? (11 answers) Closed 5 years ago . I am working on porting code from JAVA to C#, and part of the JAVA code uses tokenizer - but it is my understanding that the resulting array from the stringtokenizer in Java will also have the separators (in this case +, -, /, *, (, )) as tokens. I have attempted to use the C# Split() function, but it seems to eliminate the separators themselves. In the end, this will parse

how to split strings in objective c

て烟熏妆下的殇ゞ 提交于 2019-11-29 06:26:52
How to split a string in objective-C? I am working on an short application that contains a date picker. I do display date get it from date picker and display it through a label. My main question is that how can I split the the date in to three separate strings? any one has idea about it? Thanks You could use -[NSString componentsSeparatedByString:] or NSScanner to split the string, or use NSCalendar to extract the pieces of the date you're interested in. Use something like [yourString componentsSeparatedByString:@"/"] . You will get an NSArray of separated strings. If you can format date into

Elasticsearch: Find substring match

风格不统一 提交于 2019-11-28 04:05:51
I want to perform both exact word match and partial word/substring match. For example if I search for "men's shaver" then I should be able to find "men's shaver" in the result. But in case case I search for "en's shaver" then also I should be able to find "men's shaver" in the result. I using following settings and mappings: Index settings: PUT /my_index { "settings": { "number_of_shards": 1, "analysis": { "filter": { "autocomplete_filter": { "type": "edge_ngram", "min_gram": 1, "max_gram": 20 } }, "analyzer": { "autocomplete": { "type": "custom", "tokenizer": "standard", "filter": [

How to get numbers out of string?

怎甘沉沦 提交于 2019-11-28 01:18:54
问题 I'm using a Java StreamTokenizer to extract the various words and numbers of a String but have run into a problem where numbers which include commas are concerned, e.g. 10,567 is being read as 10.0 and ,567. I also need to remove all non-numeric characters from numbers where they might occur, e.g. $678.00 should be 678.00 or -87 should be 87. I believe these can be achieved via the whiteSpace and wordChars methods but does anyone have any idea how to do it? The basic streamTokenizer code at

Elasticsearch: Find substring match

早过忘川 提交于 2019-11-27 00:13:36
问题 I want to perform both exact word match and partial word/substring match. For example if I search for "men's shaver" then I should be able to find "men's shaver" in the result. But in case case I search for "en's shaver" then also I should be able to find "men's shaver" in the result. I using following settings and mappings: Index settings: PUT /my_index { "settings": { "number_of_shards": 1, "analysis": { "filter": { "autocomplete_filter": { "type": "edge_ngram", "min_gram": 1, "max_gram":

Sending an array of values to Oracle procedure to use in WHERE IN clause

喜欢而已 提交于 2019-11-26 21:07:13
I have a stored procedure in Oracle as shown below: CREATE PROCEDURE MY_TEST_PROC( CUR OUT SYS_REFCURSOR, PARAM_THAT_WILL_BE _USED_INSIDE_WHERE_IN ) AS BEGIN OPEN CUR FOR SELECT * FROM MY_TABLE WHERE COL1 IN (here I want to put values received from C#) END; On the ASP.NET application side I have a select element with several options. I want to use these list items in my WHERE clause. I know that I can have a VARCHAR2 input parameter in my stored proc, make a comma separated string from the list items, send it to the procedure. There are two concerns with going this way: I make my website

Performance of StringTokenizer class vs. String.split method in Java

大城市里の小女人 提交于 2019-11-26 15:08:27
In my software I need to split string into words. I currently have more than 19,000,000 documents with more than 30 words each. Which of the following two ways is the best way to do this (in terms of performance)? StringTokenizer sTokenize = new StringTokenizer(s," "); while (sTokenize.hasMoreTokens()) { or String[] splitS = s.split(" "); for(int i =0; i < splitS.length; i++) If your data already in a database you need to parse the string of words, I would suggest using indexOf repeatedly. Its many times faster than either solution. However, getting the data from a database is still likely to