Results 1 to 2 of 2

Thread: search problem

  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default search problem

    i have to search in a string like this line

    "TEXT('Plan','Design',3,1.0000000E-5,#36,#37);"

    and get only the pattern like [#number] and get all

    then our search return #36,#37

    any help ?

  2. #2
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    you can use regular expression
    Java Code:
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    public class RegexDemo {
        public static void main(String[] args){
            String string = "TEXT('Plan','Design',3,1.0000000E-5,#36,#37);";
            Pattern ex = Pattern.compile("#\\d+");
            Matcher match = ex.matcher(string);
            while (match.find() ){
                System.out.println( match.group() );
            }
        }
    }

Similar Threads

  1. i have a problem with search in java
    By mikethebiker in forum New To Java
    Replies: 1
    Last Post: 11-10-2010, 10:53 AM
  2. Binary search problem
    By billy in forum New To Java
    Replies: 3
    Last Post: 10-08-2010, 08:43 PM
  3. problem with linear search
    By Metastar in forum New To Java
    Replies: 14
    Last Post: 09-14-2010, 08:01 PM
  4. Binary Search Problem
    By sharpnova in forum New To Java
    Replies: 2
    Last Post: 02-19-2009, 10:22 AM
  5. Help. Binary Search Problem
    By Krooger in forum Advanced Java
    Replies: 1
    Last Post: 11-03-2008, 06:19 AM

Posting Permissions

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