Javascript regular expression for punctuation (international)?

后端 未结 6 1259
难免孤独
难免孤独 2020-12-05 10:22

I need a regular expression to match against all punctuation marks, such as the standard [,!@#$%^&*()], but including international marks like the upside-down Spanish qu

6条回答
  •  渐次进展
    2020-12-05 11:28

    Your regex would look something like...

    /[,!@#$%^&*()\u9999]/
    

    Where you replace each \u9999 with the Unicode codepoint for the other punctuation characters.

    If you could find a bunch in a range, you could specify that with the - range operand, e.g. \u9990-\u9999.

    As far as I know you can't use something like \pP in JavaScript regexes.

提交回复
热议问题