请问[tag]******[/tag],tag可以为任意,用正则表达式截取中间*号的内容该怎么写呀?
正则表达式
------解决方案--------------------
public static void main(String[] args) {
String str1 = "[tag]asdf ddd 111[/tag]";
Pattern p = Pattern.compile("\\[tag\\](.*)\\[/tag\\]");
Matcher m = p.matcher(str1);
if(m.find())
{
System.out.println(m.group(1));
}
}
------解决方案--------------------
\\[tag\\](.+?)\\[tag\\]