in reply to *fixed*Problem with <> and regex

If you really want to reduce:
<span class="author-name" itemprop="author">Romaxton</span>
you could use something like this (untested):
s/<[^>]+(\w+)/$1/;

Replies are listed 'Best First'.
Re^2: *fixed*Problem with <> and regex
by AnomalousMonk (Archbishop) on Mar 11, 2014 at 22:54 UTC

    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>'
      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+)</;