Java を使用して、ドル記号の間の単語を抽出したいと考えています$
。
例えば:
String = " this is first attribute $color$. this is the second attribute $size$"
文字列を引き出したい:color
そしてsize
それらをリストに入れます。
私が試してみました:
Pattern pattern = Pattern.compile("(\\$) .* (\\$)");
Matcher matcher = pattern.matcher(sentence);
しかし、私は出力を取得します:
"$color$.this is the second attribute $size$"
これを行う最善の方法は何ですか?