in reply to Re: Re: Regex simplification
in thread [untitled node, ID 192753]
This is good, but it \S is shorter than [^\s], so:print $1 if $line =~ m/<!-- USER \d+ - ([^\s]+)/i;
Although to get a little closer to the original specification, I'd put:print $1 if $line =~ m/<!-- USER \d+ - (\S+)/i;
my $user=undef; for (@site) { if (/<!--.*USER.* (\S+) -->/) { print "joe:\n"; $user = $1; last; } } print "user = $user\n";
|
|---|