in reply to problem with optional capture group
#!/usr/bin/perl use strict; use feature qw{ say }; use warnings; for my $line ('<div id="roguebin-response-35911" class="bin-response"> +</div>', '<div id="roguebin-response-35911" class="bin-response"> +' ) { if ($line =~ m{<div.+(</div)|<div.+}) { say "line matched"; if (defined $1) { say "right after match, 1 is defined: $1"; } } }
|
|---|