Saturday, 31 August 2013

Clarification in usage of Regular Expressions in Java

Clarification in usage of Regular Expressions in Java

I am new to Regex. Please correct me where am doing wrong in below code.
Also Please suggest some nice books/tutorials in Java-Regex.
public class regexx {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s = "Bug 2742";
if("^Bug [0-9]*".matches(s)){
System.out.println("eq");
}else {
System.out.println("nq");
}
}
}
Am expecting "eq" as output.But the match is returning false.

No comments:

Post a Comment