I have the following regullar expression which matches any characters at the beginning ending with text in parenthesis "Hi (Stackoverflow)"
. When I enter this text to be matched the program does not finish with result. It is still running without finishing.
String pattern = "^[a-zA-Z]+([\\s]*[\\w]*)*\\([\\w]+\\)"
String text = "Asdadasdasd sadsdsad sdasd (s)"
String text2 = "Asdadasdasd sadsdsad sdasd (s) sdsd"
System.out.println(text.matches(pattern)) - it works
System.out.println(text2.matches(pattern)) - never ending story
What is wrong?
Aucun commentaire:
Enregistrer un commentaire