How to match hyphens with Regular Expression?

后端 未结 6 1116
[愿得一人]
[愿得一人] 2020-11-21 23:36

How to rewrite the [a-zA-Z0-9!$* \\t\\r\\n] pattern to match hyphen along with the existing characters ?

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-21 23:48

    use "\p{Pd}" without quotes to match any type of hyphen. The '-' character is just one type of hyphen which also happens to be a special character in Regex.

提交回复
热议问题