I have this regex
regex = ~/\"([^"]*)\"/
so Im looking for all text between quotes now i have the follow开发者_开发百科ing string
options = 'a:2:{s:10:"Print Type";s:8:"New Book";s:8:"Template";s:9:"See Notes";}'
however doing
regex.matcher(options).matches() => false
should this not be true, and shouldn't I have 4 groups
The matcher()
method tries to match the entire string with the regex which fails.
See this tutorial for more info.
I don't know Groovy, but it looks like the following should work:
def mymatch = 'a:2:{s:10:"Print Type";s:8:"New Book";s:8:"Template";s:9:"See Notes";}' =~ /"([^"]*)"/
Now mymatch.each { println it[1] }
should print all the matches.
精彩评论