这样就行:
[code="java"]public class TestRegex {
// 不要求配对,只要求对〖和〗做单独替换的话:
private static void test1(String src, String expected) {
String result = src.replaceAll("〖", "").replaceAll("(?<!/)〗", "");
System.out.println(expected.equals(result));
}
// 要求〖和〗配对才做替换的话:
private static void test2(String src, String expected) {
String result = src.replaceAll("〖(.*?)(?<!/)〗", "<u>$1</u>");
System.out.println(expected.equals(result));
}
public static void main(String[] args) {
String src = "I'd like u,〖124/〗5〗,but u don`t like me at all,〖ppp〗llll";
String expected = "I'd like u,<u>124/〗5</u>,but u don`t like me at all,<u>ppp</u>llll";
test1(src, expected);
test2(src, expected);
}
}[/code]
不过你最好确认一下你对匹配的描述是不是真的符合你的需要,例如说"〖"之前如果出现"/"需不需要考虑转义的问题。