开发者

Filtering using Regular Expressions

I am having a filter for the following regular expressions

[^@()[]\;:,<>]+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/

I need to negate the following special charters before the @domain.com

@()[]开发者_开发百科\;:",<

any suggestions??


Try escaping the ] in the character class.

[^@()[\]\;:,<>]+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
      ^^

If not escaped the ] will be treated incorrectly as the end of the character class.

Since this has been tagged as Java, remember that you need to escape using \\ and not just \.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜