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