[clue-tech] Simple Perl regex
Jed S. Baer
cluemail at jbaer.cotse.net
Thu Dec 16 18:10:15 MST 2010
Well, I must be fogbound, because I don't see why this regex I've written
doesn't work.
Goal: given a string containing:
blah xmlUrl="stuph I want to extract" more blah
grab the string inside the quote marks, introduced by 'xmlUrl='.
So I have this:
if ( $foo =~ /xmlUrl=\"(.+?)\"/ ) {
# if we get here, then $1 is stuph I want to extract
print "$1\n";
}
So maybe it's been too long since I've written Perl, but IIRC (and
according to a couple doc pages I just read), stuff matching inside
parens is assigned to $1, $2 ..., and ? makes the repeat non-greedy.
Seems perfect! :)
But it don't print nothing. :(
--
Ok, so we should be thinking of a lovable, cuddly, stuffed penguin
sitting down after having gorged itself on herring. Still with me?
-- Linus Torvalds
More information about the clue-tech
mailing list