Reputation: 1161
What would be a regex pattern for the following ' and ® in Java. I have tried the following but have not been successful
&#[0-1][0-1][0-1]
&#\d\d
Upvotes: 0
Views: 706
Reputation: 4470
Ok, then it should be:
str.matches(".*&#\\d{1,3};.*");
This matches &# followed by 1, 2 or 3 digits and then a ;)
Upvotes: 2
Reputation: 8534
These should work:
".*\\x27.*"
matches an embedded apostrophe".*\\xae.*"
matches an embedded registered trademark symbolI tested with String.match
If you need longer unicode values you can use
".*\\u0027.*"
matches an embedded apostrophe".*\\u00ae.*"
matches an embedded registered trademark symbolSee http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html
Upvotes: 0