开发者

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

  1. &#[0-1][0-1][0-1]开发者_开发技巧
  2. &#\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:

  1. ".*\\x27.*" matches an embedded apostrophe
  2. ".*\\xae.*" matches an embedded registered trademark symbol

I tested with String.match

If you need longer unicode values you can use

  1. ".*\\u0027.*" matches an embedded apostrophe
  2. ".*\\u00ae.*" matches an embedded registered trademark symbol

See http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜