in reply to Re: regex pattern matches
in thread regex pattern matches

The angle brackets ('<' & '>') are not regex metacharacters so need not be escaped. Choosing a different pattern delimiter would mean that nothing needs to be, making the pattern a little easier on the eye.

$ 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