Java Mathjax字符串的正则表达式
任何主体都给出了如何使用正则表达式删除字符串中的Java Mathjax字符串的正则表达式,java,regex,Java,Regex,任何主体都给出了如何使用正则表达式删除字符串中的mathjax的解决方案。例如,我的输入字符串是 “哪句话解释了为什么$!\overline{AB}!$的斜率等于$!\overline{BC}!$?”,我期望的是“哪句话解释了的斜率等于的斜率?”您可以尝试以下方法: \$!.*?!\$ 示例代码 final String regex = "\\$!.*?!\\$"; final String string = "Which sentence explains why the
mathjax
的解决方案。例如,我的输入字符串是
“哪句话解释了为什么$!\overline{AB}!$
的斜率等于$!\overline{BC}!$?
”,我期望的是“哪句话解释了的斜率等于的斜率?”您可以尝试以下方法:
\$!.*?!\$
示例代码
final String regex = "\\$!.*?!\\$";
final String string = "Which sentence explains why the slope of $!\\overline{AB}!$ is equal to the slope of $!\\overline{BC}!$?";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
final String result = matcher.replaceAll("");
System.out.println(result);
您可以执行
yourstring.replaceAll($!!!$,“”)代码>它对我不起作用。