Java regular expression to match _all_ whitespace characters

前端 未结 7 390
别那么骄傲
别那么骄傲 2020-12-08 02:36

I\'m looking for a regular expression in Java which matches all whitespace characters in a String. \"\\s\" matches only some, it does not match   and s

相关标签:
7条回答
  • 2020-12-08 03:05

    In case anyone runs into this question again looking for help, I suggest pursuing the following answer: https://stackoverflow.com/a/6255512/1678392

    The short version: \\p{javaSpaceChar}

    Why: Per the Pattern class, this maps the Character.isSpaceChar method:

    Categories that behave like the java.lang.Character boolean ismethodname methods (except for the deprecated ones) are available through the same \p{prop} syntax where the specified property has the name javamethodname.

    👍

    0 讨论(0)
提交回复
热议问题