private static final String TEXT = "this a test 1: $\$$,test 2: $\underline{\rm defund}$, test 3:$$\underline{\rm defund}$$";
其他人告诉我一个python模式:
re.compile(r'(?=([^\]?))(?:(?P<bound2>$$)|$)(.*?[^\])(?:(?(bound2)$$|$))', re.S)
预期:$$$ or $, $underline{rm defund}$ or underline{rm defund}
但是我在android中使用它,Java不支持express pattern
.谁可以为我写一个Java Pattern
或给我一些提示?
在java中,只有很少的修改。
1。转义$
的反斜杠2。使用双引号
你的新代码现在看起来像这样
Pattern.compile("(?=([^\]?))(?:(?P<bound2>\$\$)|\$)(.*?[^\])(?:(?(bound2)\$\$|\$))");
注意:确保你导入了你的模式类