The Artima Developer Community
Sponsored Link

Java Answers Forum
REGEXP

1 reply on 1 page. Most recent reply: Sep 9, 2002 6:24 AM by Raghavendra Joshi

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Larry Meyers

Posts: 1
Nickname: lmeyers
Registered: Sep, 2002

REGEXP Posted: Sep 9, 2002 5:50 AM
Reply to this message Reply
Advertisement
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!


Raghavendra Joshi

Posts: 1
Nickname: joshi
Registered: Sep, 2002

Re: REGEXP Posted: Sep 9, 2002 6:24 AM
Reply to this message Reply
> 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.

Flat View: This topic has 1 reply on 1 page
Topic: about jdbc DNS Previous Topic   Next Topic Topic: JAVA Applet connected to Access

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use