I am using java.util.regex for matching like bellow
public static void main(String[] args) {
String input = "<b>I love you (LT): </b>xxxxxxxxxxxxxxxxxxxxxxxxx";
String patternStr = "I love you (LT):";
String noParentStr = "I love you";
Pattern pattern = Pattern.compile(patternStr);
Pattern noParentPattern = Pattern.compile(noParentStr);
Matcher matcher = pattern.matcher(input);
Matcher noParrentTheseMatcher = noParentPattern.matcher(input);
System.out.println("result:" + matcher.find());
System.out.println("result no parenthese:" + noParrentTheseMatcher.find());
}
I can see the input
string contain patternStr
"I love you (LT):". But I get the result
result:false
result no parenthese:true
How can i match string contain parentheses '(',')'