String text = "[! hello ¡world ¡] otra cosa ¡]";
String pt = "\\[!(.*)¡\\]";
Matcher mc = Pattern.compile(pt).matcher(text);
while(mc.find()){
System.out.println(mc.group(1));
}
此代码打印hello ¡world ¡] otra cosa
。在java中匹配正则表达式
什么样的模式只能匹配hello ¡world
?
我没有找到的是一种否定字面字符串而不是字符的方法。例如:([^(¡\])]*)
问题是:
如何匹配所有不是文字字符串的东西?
你会发现这个链接方便的与Java播放时正则表达式:http://www.regexplanet.com/simple/index.html – hexium 2009-11-17 21:18:42