想把str转换成str1的形式,正则表达式应该怎么写(java的,不要JS的)?
String str = "测试[localimg=200,300]1.jpg[/localimg],测试结束";
String str1 = "测试[img]1.jpg[/img],测试结束";
------解决方案--------------------
String str = "测试[localimg=200,300]1.jpg[/localimg,测试结束";
String str1 = "";
str1=str.replaceAll("(\\[(localimg).*?\\](.*?)\\[/\\2\\])", "[img]$3[/img]")
System.out.println(str1);