Regex pattern in java
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
Ok, then it should be:
str.matches(".*&#\\d{1,3};.*");
This matches &# followed by 1, 2 or 3 digits and then a ;)
These should work:
".*\\x27.*"
matches an embedded apostrophe".*\\xae.*"
matches an embedded registered trademark symbol
I tested with String.match
If you need longer unicode values you can use
".*\\u0027.*"
matches an embedded apostrophe".*\\u00ae.*"
matches an embedded registered trademark symbol
See http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html
精彩评论