Reputation: 67
I am trying to write a regex matcher, where by the string should start with 'Feb' , have a space, and then followed by 2 digits.
String x = "Feb 04 |";
String regex = "^Feb d{2}";
Pattern p = Pattern.compile(regex);
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(x);
while (matcher.find())
{
System.out.print("FOUND");
}
'String regex = "^Feb";'
does well to detect if it starts with Feb, but trying to detect there is a space followed by 2 digits.
Upvotes: 0
Views: 41
Reputation: 3410
The regex pattern ^Feb\s\d{2}
matches Feb, a white space, and two digits.
[edit]
^Feb\s\d{2}.*$
if you want to match the full string
Upvotes: 2