2016-12-14 16 views
1

本文には、正規表現を使用して文字列内のmathjaxを削除する方法の解説があります。たとえば、私の入力文字列はMathjax文字列の正規表現

の勾配が$!\overline{BC}!$?の勾配と等しい理由を説明する文章です。

+0

あなたは 'yourstring.replaceAll( "$ * $!。!" を、 "")を行うことができます。 ' – GurV

+0

私はうまく動かない。 –

答えて

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

あなたは働いてくれてありがとうございます。 –