|
Re: REGEXP
|
Posted: Sep 9, 2002 6:24 AM
|
|
> All I want to do is take a string (1,2,3,4,5,6,7-15) > and display all the numbers > (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) Any help would > be greatly appreciated. Where do I start or which > class would be best to use. Thanks again!
Hi, You can use StringTokenizer which is available in util package. You can specify the token-separator, which, in this case, will be left-open-brace, comma and right-close-brace. It allows you to get the tokens out of the expression.
Once you get the token, you need to perform some priliminary processing as mentioned below: (a)If you can convert the token to integer, the add it to the target list. (b) If there is NumberFormatException, then the token string specifies range ex: 7-15. In this case, you need to add a list of values.
I hope this will solve the problem.
|
|