I have an example dynamic input of information like this:
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)
I am trying to use Regex in Android to split the string into three parts:
- Text before XXX()
- Text in (XXX)
- Text after () XXX
Sometimes there won’t be a price, the text after the location in ().
I’ve tried to
Pattern p = Pattern.compile("\(([^]*)\)");
Matcher m = p.matcher(title);
But I can’t get matchers to work in Android. It always returns empty when I look in with matcher.group(1). I have it setup currently to look for either ( or $ and explode too give me the separate strings. But this is inaccurate and inefficient.
Any help is apperciated!
I suspect you could do this with a regular expression, but it might be simpler not to.
prints