http://www.perlmonks.org?node_id=929242


in reply to Re^2: Why do these regex variants behave as they do?
in thread Why do these regex variants behave as they do?

if ( $string4 =~ />(?:([\s|\w]+))(?:<\/td>)/m ) { ... }

In  (?:([\s|\w]+)) the '|' (pipe) character in the character set is taken literally (i.e., the set matches any whitespace, word or '|' character) and so is probably not what you intend! Also, the non-capturing grouping is redundant:  ([\s\w]+) should work just as well. Further, the  (?:<\/td>) at the end (in which the non-capturing grouping is also redundant) requires a positive match on this sequence of characters, whereas in previous code this was a  (?!<\/td>) zero-width, negative look-ahead assertion; don't know if this difference was intended or not (Update: although on second thought it probably was intended since it was the negative look-ahead that led to the missing-final-character puzzlement).