in reply to Re: *fixed*Problem with <> and regex
in thread *fixed*Problem with <> and regex

That doesn't actually work:

c:\@Work\Perl>perl -wMstrict -le "my $s = '<span class=\"author-name\" itemprop=\"author\">Romaxton</sp +an>'; ;; $s =~ s/<[^>]+(\w+)/$1/; print qq{'$s'}; " 'r">Romaxton</span>'

Replies are listed 'Best First'.
Re^3: *fixed*Problem with <> and regex
by Laurent_R (Canon) on Mar 12, 2014 at 18:43 UTC
    Yes, you are right. I was not in a position to test when I posted and I missed parts of it. I was thinking about something like this (assuming the string is in $_):
    s/<[^>]+>(\w+).*/$1/;
    which does work, but there are actually some easier ways, such as:
    print $1 if />(\w+)</;