我有动态字符串,有时会有价格,有时没有。它适用于 craigslist,因此实际上没有固定格式,可以是逗号、破折号等。以下是典型字符串的一些示例:
Xbox 360 (black) Elite Console 120GB (Mason City Illinois ) $200
$200 2013 North Trail Camper (RT 202. Manchester, Maine) $224/mo.
Snowmobile Bike trailers (Winthrop / Augusta) $40 Monthly
"Great Xmas Gift" XBox 360 Guitar Hero (Springfied) $80
我正在尝试将字符串拆分为标题、位置和价格。我可以通过以下方式获取位置:
Pattern p = Pattern.compile("\(([^]*)\)");
Matcher m = p.matcher(title);
无法弄清楚如何将标题和价格分开。任何帮助将不胜感激。
最佳答案
要在 $
之后获取数字,请使用:\$[0-9]+
正则表达式。
关于android - 美元符号后的正则表达式抓取数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13736490/