$ perl -E ' $text = q{asd<TAG>dsyuhf</TAG>urrh}; $item = $1 if $text =~ m{<TAG>([^<]+)</TAG>}; say $item;' dsyuhf $
Note also that I capture ([^<]+) because (.*) is greedy.
$ perl -E ' $text = q{asd<TAG>dsyuhf</TAG>urrh<TAG>dsvnnhf</TAG>urubb}; $item = $1 if $text =~ m{<TAG>(.*)</TAG>}; say $item;' dsyuhf</TAG>urrh<TAG>dsvnnhf $
I hope this is useful.
Cheers,
JohnGG
In reply to Re^2: regex pattern matches
by johngg
in thread regex pattern matches
by argos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |