![](/img/trans.png)
[英]Java : Pattern How to match any character or symbol in any order between the two braces
[英]Java pattern to match any character except exclamatory symbol
我有一个数据流,我只想获取那些与模式匹配的字符串。 我看过其他示例,但是我的示例有点棘手,因为它包含感叹号。
这是一个示例数据
!P this is a test !!
我的结束顺序是! 并且开始顺序是!P。 我想使用模式匹配器来捕获上面的整个字符串。 我可以使用以下模式获取此数据
Pattern.compile("!U[^!]*!!", Pattern.DOTALL);
运用
[^!]*
我正在过滤是否有以下情况:
!P this should not come !P this should come !!
但是[^!] *仅适用于单个字符,我想确保以!P进行过滤,并确保仅获得以!P开头并以!!结尾的有效模式。 消除无效的启动和停止。
我想过滤情况如下:
!P this should come !! this should not come !!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.