You shouldn't need to clean up results (or use an if statement like that). Use the "find" method (on groovy 1.6.1 and above):
def sent = "Hall of Fame"
sent.find(/(\S+)\s(\S+)\s(\S+)/) { full, first, second, third ->
println first
println second
println third
}
prints:
Hall
of
Fame
On Thu, Jun 25, 2009 at 7:14 AM, Harsha1
<99harsha.h.n99@...> wrote:
Hi,
I have to clear the result from the Matcher class which gets generated after
=~
I have code like this...
int i = 0
def sent = 'Hall Of Fame'
if(sent =~ "([^\\s]+\\s[^\\s]+\\s[^\\s]+)")
{
/* HERE I NEED TO CLEAR THE RESULT, Which is thr in
Matcher class */
sent =~ "([^\\s]+)\\s([^\\s]+)\\s([^\\s]+)"
println Matcher.lastMatcher[0][1]
println Matcher.lastMatcher[0][2]
println Matcher.lastMatcher[0][3]
}
--
View this message in context: http://www.nabble.com/How-to-clean-up-results-in-Matcher-Class--tp24202110p24202110.html
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email