我是 Java 正则表达式概念的新手。
谁能告诉我应该用于以下字符串的正确正则表达式 -
String exp = "ABCD_123_abc".
我用于上述字符串的正则表达式是:
regExp = "([a-zA-Z]+)_([0-9]+)_([a-z]+)"
但是下面代码的输出是"**No Match Found**"
Public static void main()
{
String exp = "ABCD_123_abc";
String regExp = "([a-zA-Z]+)_([0-9]+)_([a-z]+)";
Pattern pattern = Pattern.compile(exp);
Matcher matcher = pattern.matcher(regExp);
if(matcher.matches())
{
System.out.println("Match found");
}
else
{
System.out.println(" NO Match found");
}
}