in reply to A regex that only matches at offset that are multiples of a given N?
I'd put . in place of ???? and then * after the first parentheses...
use v5.12; my @should_match = ( q[foo], q[WXYZfoo], q[WXYZWXYZfoo], q[WXYZ WXYZfoo], ); my @should_not_match = ( q[ foo], q[ABCfoo], q[VWXYZfoo], q[WXYZWXYZWXYZAfoo], ); my $regexp = qr{^(?:.{4})*foo}; say /$regexp/ ? "ok" : "not ok" for @should_match; say /$regexp/ ? "not ok" : "ok" for @should_not_match;
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: A regex that only matches at offset that are multiples of a given N?
by BrowserUk (Patriarch) on Feb 13, 2013 at 16:24 UTC | |
by tobyink (Canon) on Feb 13, 2013 at 17:11 UTC | |
by BrowserUk (Patriarch) on Feb 13, 2013 at 17:18 UTC | |
by BrowserUk (Patriarch) on Feb 16, 2013 at 00:29 UTC | |
by choroba (Cardinal) on Feb 13, 2013 at 16:31 UTC | |
by BrowserUk (Patriarch) on Feb 13, 2013 at 16:36 UTC | |
by ikegami (Patriarch) on Feb 14, 2013 at 07:50 UTC |
In Section
Seekers of Perl Wisdom