开发者

Regex pattern in java

开发者 https://www.devze.com 2023-03-25 22:09 出处:网络
What would be a regex pattern for the following'and ® in Java.I have tried the following but have not been successful

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

精彩评论

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