Hi - I'm trying to figure out a Java regex problem that I'm having. This is 1.6, but I don't think that matters. Anyway...
I'm going to have some input data like the following...
"Blah yadda yidda 44-Barack Obama, this that the other"
or
"Something here, there 22-Hyphenated-example. Hi there folks"
Basically I want to extract everything following the number through to the trailing punctuation. In the two examples inputs I want to extract...
"Barack Obama"
and
"Hyphenated-example"
I can't quite get the pattern I need to use. The closest I can get is this...
"[0-9]{1,2}-([A-Z -]*\\b*)"
that, however, gives me...
"44-Barack Obama"
My code is...
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher("Blah yadda yidda 44-Barack Obama, this that the other");
if (matcher.find())
// This gives me "44-Barack Obama" but I want "Barack Obama".
System.out.println(matcher.group());
Interestingly, I'm using the QuickREx Eclipse plugin to test this pattern and it returns the proper value. However, running the above code does not.
Any ideas?