有没有办法在正则表达式(java)中使用\p {Punct},但没有“(”,“,”)“字符? [英] Is there a way to use \p{Punct} in a regex(java), but without the "(",")" characters?
本文介绍了有没有办法在正则表达式(java)中使用\p {Punct},但没有“(”,“,”)“字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在java中的正则表达式中使用模式 \p {Punct} ,但没有两个字符(
和)
?
Is there a way to use the patter \p{Punct} in a regex in java, but without the two characters (
and )
?
推荐答案
你应该可以使用:
[\p{Punct}&&[^()]]
这是说:
punct
字符类除了(
和)
。
^
字符指定负字符类。 &&&
是 punct
类与括号的自定义类之间的交集。
The ^
character specifies a negative character class. The &&
is an intersection between the punct
class and the custom class for the parenthesis.
看看 模式
Javadocs获取更多信息。
Have a look at the Pattern
Javadocs for more info.
这篇关于有没有办法在正则表达式(java)中使用\p {Punct},但没有“(”,“,”)“字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文