Results 1 to 3 of 3
  1. #1
    saidinu is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

    Unhappy identify the delimiter..

    Dear friends

    Could you help me with the following

    I am working with the stringtokenizer.

    I would like to write the query based on the delimiter.for ex:

    if user enter 1-5 , i need to search the values in the the range between 1 and 5.
    if user enter 1,3. i need to search the values for 1 and 3
    How can I do this using stringtokenizer or there is anyother way to proceed.
    writing the query is not the prob, but how can i identify the delimiter.

    thank you in advance

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,585
    Rep Power
    25

    Default Re: identify the delimiter..

    What is the pattern for the input?
    <numeric digit(s)><single delimiter char><numeric digit(s)>

    You might be able to use a regular expression to parse this. I'm not much with regex's so I'll leave this to some one that is.

  3. #3
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: identify the delimiter..

    StringTokenizer (Java Platform SE 6)
    StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code.

    I`m not sure if I understood you correctly:
    Java Code:
    		String s = "The 1st example line. The 2nd one. The 6th line.";
    		String one = "1-7";
    		String two = "1,6";
    		
    		Matcher m = Pattern.compile("["+one+"]").matcher(s);
    		while(m.find()){
    			System.out.println(m.group());
    		}
    		System.out.println("----");
    		m = Pattern.compile("["+two+"]").matcher(s);
    		while(m.find()){
    			System.out.println(m.group());
    		}
    ???

Similar Threads

  1. How to identify a roman numeral
    By dunworry in forum New To Java
    Replies: 13
    Last Post: 12-19-2010, 08:13 AM
  2. Identify pixel in the image.
    By Maiquelnet in forum Java 2D
    Replies: 2
    Last Post: 11-12-2009, 07:55 PM
  3. How to identify packet type?
    By priya deshpande in forum Networking
    Replies: 0
    Last Post: 10-11-2009, 06:40 AM
  4. delimiter
    By satin in forum New To Java
    Replies: 2
    Last Post: 11-17-2008, 10:50 PM
  5. identify a thread
    By valery in forum Advanced Java
    Replies: 1
    Last Post: 07-25-2007, 01:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •