This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Groovy and the fly likes GinA Example - Can anyone explain how it works Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "GinA Example - Can anyone explain how it works" Watch "GinA Example - Can anyone explain how it works" New topic
Author

GinA Example - Can anyone explain how it works

Kristian Jones
Greenhorn

Joined: Jun 26, 2008
Posts: 6
Hi Guys,
The following code is a modified example from Groovy in Action but I don't understand what it does.




I never seem to be able to get the 'matched candidate with regex' (which is what I think the code is supposed/!supposed to do) regardless of how I change the 1st / 3rd argument. Has anyone got any suggestions on what needs to be changed in order to make it work and print out this line.

The code is from page 165 of the book and I'm using groovy 1.6.5

Thanks
Kris
Dave Klein
author
Ranch Hand

Joined: Aug 29, 2007
Posts: 77
It looks like you had a couple minor errors in the regex:

GinA page 165 code has this:
and your example has this:
Notice the sequence: ".[a-zA" from GinA. Your example has ".=a-za"

I hope that helps,
Dave


Author of Grails: A Quick-Start Guide
Kristian Jones
Greenhorn

Joined: Jun 26, 2008
Posts: 6
Doh, school boy error. Can't believe I didn't check the pattern first.


Thanks again.
Kris
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GinA Example - Can anyone explain how it works
 
Similar Threads
First hand at RegEx
Seemingly simple regex making my head hurt
Pattern Matching
Replace text by HTML links
i am validating email on server side