in reply to Matching with /g: Is this a bug?
This is the documented behaviour. Add the /c flag to the second match to keep the position even after the failed match. See perlre for details.#!/usr/bin/perl use strict; use warnings; my $s = << '__STRING__'; hubba1 bubba hubba2 __STRING__ $s =~ /bubba/gm; $s =~ /no match/gm; print $s =~ /(hubba\d)/gm;
|
|---|