title: How Match a Pattern in Text using Scanner and Pattern Classes?
body: <p>i want to find whether a particular pattern exists in my text file or not.</p>
  
  <p>i m using following classes for this :</p>
  
  <pre><code>java.util.regex.Pattern and java.util.Scanner;
  </code></pre>
  
  <p>my sample text Line is</p>
  
  <pre><code>String Line="DBREF  1A1F A  102   190  UNP    P08046   EGR1_MOUSE     308    396";
  </code></pre>
  
  <p>and, i want to match following kind of pattern :</p>
  
  <pre><code>A    102   190
  </code></pre>
  
  <p>where, at A's position a-z or A-Z but single charter.</p>
  
  <p>at 102's position any integer and of any length.</p>
  
  <p>at 190's position any integer and of any length.</p>
  
  <p>and,My code for pattern matching is:</p>
  
  <pre><code>     Scanner sr=new Scanner(Line);
       Pattern p = Pattern.compile("\\s+([a-zA-Z]){1}\\s+\\d{1,}\\s+\\d{1,}\\s+");
       while(sr.hasNext(p))
       {
           System.out.println("Pattern exists");
           System.out.println("Matched String : "+sr.next(p));
       }
  </code></pre>
  
  <p>but,
       pattern is not matching even it exist there..</p>
  
  <p>i think the problem is with my pattern string :</p>
  
  <pre><code>\\s+([a-zA-Z]){1}\\s+\\d{1,}\\s+\\d{1,}\\s+"
  </code></pre>
  
  <p>anybody, Plz help me what pattern string should i use???? </p>