Regex to Match Symbols: !$%^&*()_+|~-=`{}[]:";'<>?,./

后端 未结 6 1841
无人共我
无人共我 2020-11-28 19:20

I\'m trying to create a Regex test in JavaScript that will test a string to contain any of these characters:

!$%^&am         


        
6条回答
  •  粉色の甜心
    2020-11-28 19:44

    The most simple and shortest way to accomplish this:

    /[^\p{L}\d\s@#]/u
    

    Explanation

    [^...] Match a single character not present in the list below

    • \p{L} => matches any kind of letter from any language

    • \d => matches a digit zero through nine

    • \s => matches any kind of invisible character

    • @# => @ and # characters

    Don't forget to pass the u (unicode) flag.

?,./" id="ans_title" name="title">
提交回复
热议问题