使用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$"
什麼是做到這一點的最好方法是什麼?
謝謝你[halex](http://stackoverflow.com/users/637284/halex),工作正常。 – rajesh