#!/usr/bin/perl use strict; use warnings; use 5.012; # 928860a $\=undef; my $string = ; #1 capture paren pair contains the non-grouping parens if ( $string =~ />((?:\s|\w)+)(?!<\td>)/m ) { say "regex 1: $1"; } # cf #1 />((?:\s|\w)+)(?!<\td>)/m # "" erroneously written as "<\td>" (escaping the "t") captures precisely as intended # cf #2 />((?:\s|\w)+)(?!<\/td>)/m # regex as intended fails to capture the terminal "g" # cf #3 />(?:(\s|\w)+)(?!<\/td>)/m # captures only the (penultimate?) "n" __DATA__ /td>Moving Services for MSCD Student Success Building
#### C:\>928860a.pl regex 1: Moving Services for MSCD Student Success Building C:\>928860b.pl regex 2: Moving Services for MSCD Student Success Buildin C:\>928860c.pl regex 3: n