开发者

Filtering using Regular Expressions

开发者 https://www.devze.com 2023-03-09 19:57 出处:网络
I am having a filter for the following regular expressions [^@()[]\\;:,<>]+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})$/

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

精彩评论

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

关注公众号