android - 美元符号后的正则表达式抓取数字

标签 android regex

我有动态字符串,有时会有价格,有时没有。它适用于 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/

相关文章:

java - 这种变量在 Android 中意味着什么? (网址...网址,整数...进度)

c++ - 在 google-api-cpp-client 中构建专门的服务 API

php - 用于查找有效文件名的正则表达式

android - "take a picture and present it"在三星 Galaxy S 的纵向模式下

java - 安卓工作室游戏开发

java - 以编程方式更改导航 View 标题图像不起作用

regex - 使用 sed/regex/bash 脚本修改版本字符串

正则表达式和 o 运算符 perl v5.10.1

mysql - 尝试将正则表达式应用于选择查询中的列

android - Camera2 Library 在 android 拍摄的照片上没有给出默认的捕捉声音