2016-12-14 213 views
1

任何机构都可以解决如何使用正则表达式删除字符串中的mathjax。比如我输入的字符串Mathjax的正则表达式字符串

“这句话解释了为什么$!\overline{AB}!$斜率等于$!\overline{BC}!$?坡”,就是我想到的是“这句话解释了为什么的斜率等于斜率?”

+0

你可以做'yourstring.replaceAll( “$ * $!。!”, “”); ' – GurV

+0

它不适合我gurwinder。 –

回答

2

你可以试试这个:

\$!.*?!\$ 

Explanation

示例代码

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); 
+1

谢谢你特立独行的工作。 –