使用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