Results 1 to 8 of 8
- 05-25-2011, 02:59 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 35
- Rep Power
- 0
- 05-25-2011, 03:22 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
Sure, you can use regular expressions for that task e.g. you can also do it manually by using one of the numerous methods implemented in the String class itself (with a bit of help from the utiliy methods in the Character class). Read the API documentation for those classes.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-25-2011, 04:34 PM #3
String (Java Platform SE 6)
Just to speed up your search in the API.- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 05-25-2011, 05:37 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 35
- Rep Power
- 0
Thanx,though what Im seeing with string functions is that you have to know the exact value of what is inside the string,is there no way you can get unknown values.
or do you have to test for every single number and letter?
- 05-25-2011, 05:42 PM #5
Not really. Then structure of the String must have some rules.have to know the exact value of what is inside the string
If you know that the tokens/words in the String are separated by some character, you can use a method in the String class to put all the tokens/words into an array. Also the StringTokenizer class will do that.
If there are no separators, eg "300dogs" then you'd have to look char by char.
- 05-25-2011, 05:59 PM #6
Member
- Join Date
- Apr 2011
- Posts
- 35
- Rep Power
- 0
Actually there is a space between the numerics and the characters. Maybe it just seems lazy but I want to get the number as a whole.
Simply put If its "300 dogs" i want to make a calculation based on the fact that they are dogs.
The checking if they are dogs is not a problem,
its the number before the space that i want to fetch and deposit in a formula.
- 05-25-2011, 06:01 PM #7
Again its a question of the format of your data. Do you know the first token is a number and the second token a String? Then parse the input into two tokens and use the Integer parse method to convert the first token to a number.
- 05-26-2011, 10:15 AM #8
Member
- Join Date
- Apr 2011
- Posts
- 35
- Rep Power
- 0
Similar Threads
-
Checking If A String Contains Symbols
By SwissR in forum New To JavaReplies: 7Last Post: 07-27-2010, 09:07 AM -
checking for ints in a String
By SteroidalPsycho in forum New To JavaReplies: 1Last Post: 03-26-2010, 06:09 PM -
Help with checking for a certain format in a String
By SteroidalPsycho in forum New To JavaReplies: 2Last Post: 03-26-2010, 04:56 AM -
Comparing contents of a file with String[]
By eponcedeleon in forum Advanced JavaReplies: 2Last Post: 02-25-2010, 09:10 PM -
spliting a string and checking each token's format
By Implode in forum New To JavaReplies: 1Last Post: 10-18-2009, 08:41 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks