Win8 Strawberry 5.8.9.5 (32) Tue 12/22/2020 16:43:09 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings for my $line ( '<div id="foo-bar-321" class="bin-boff"></div>', '<div id="foo-bar-321" class="bin-boff"> </div>', '<div id="foo-bar-321" class="bin-boff">foo</div>', '<div id="foo-bar-321" class="bin-boff"> foo </div>', '<div id="foo-bar-321" class="bin-boff">', '<div id="foo-bar-321" class="bin-boff"> ', '<div id="foo-bar-321" class="bin-boff">foo', '<div id="foo-bar-321" class="bin-boff"> foo', ) { if ($line =~ m{ <div (?: (?! </div) .)+ (</div)? }xms) { print "line matched \n '$&' \n"; if (defined $1) { print " right after match, \$1 is defined '$1' \n"; } } } ^Z line matched '<div id="foo-bar-321" class="bin-boff"></div' right after match, $1 is defined '</div' line matched '<div id="foo-bar-321" class="bin-boff"> </div' right after match, $1 is defined '</div' line matched '<div id="foo-bar-321" class="bin-boff">foo</div' right after match, $1 is defined '</div' line matched '<div id="foo-bar-321" class="bin-boff"> foo </div' right after match, $1 is defined '</div' line matched '<div id="foo-bar-321" class="bin-boff">' line matched '<div id="foo-bar-321" class="bin-boff"> ' line matched '<div id="foo-bar-321" class="bin-boff">foo' line matched '<div id="foo-bar-321" class="bin-boff"> foo'
Give a man a fish: <%-{-{-{-<
In reply to Re^3: problem with optional capture group
by AnomalousMonk
in thread problem with optional capture group
by Special_K
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |