Is there a way to use \p{Punct} in a regex(java), but without the “(”,“)” characters?

后端 未结 2 772
無奈伤痛
無奈伤痛 2021-02-07 16:56

Is there a way to use \\p{Punct} in a regex in java, but without the two characters ( and ) ?

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 17:26

    This should work:

    [\p{Punct}&&[^()]]
    

    && is the intersection operator for character classes, so the intersection of \p{Punct} and [^()] is what you're after. See Character Classes.

提交回复
热议问题