简体   繁体   中英

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 \ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM