String text = "[! hello ¡world ¡] otra cosa ¡]";
String pt = "\\[!(.*)¡\\]";
Matcher mc = Pattern.compile(pt).matcher(text);
while( mc.find() ){
System.out.println(mc.group(1));
}
Run Code Online (Sandbox Code Playgroud)
此代码打印hello ¡world ¡] otra cosa.
什么是只匹配的模式hello ¡world?
我找不到的是一种否定文字字符串而不仅仅是字符串的方法.就像是:([^(¡\])]*)
问题是:
如何匹配不是文字字符串的所有内容?
| 归档时间: |
|
| 查看次数: |
1504 次 |
| 最近记录: |