【发布时间】:2012-10-21 21:29:50
【问题描述】:
使用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$"
最好的方法是什么?
【问题讨论】: