我是Java新概念正則表達式的概念。RegExp混淆
誰能告訴我,我應該爲下面的字符串中使用正確的正則表達式 -
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");
}
}
你在回答問題後是否修復了問題中的代碼?這很混亂。 – MikeFHay 2013-03-19 11:48:34