I want to use negative lookbehind with quantifiers. But I have the error. I use Perl.
I have several text files and I need to detect that they have special text prefix before the distinct word.
Error:
A quantifier inside a lookbehind makes it non-fixed width
My regular expression:
/(?<!big([\s]+)?)dog/
I want to get the fourth and fifth number.
1. bigdog - not ok
2. big dog - not ok
3. big dog - not ok
4. dog - ok
5. dog any text except big. dog - ok
You can use the SKIP and FAIL verbs.
#! /usr/bin/perl
use warnings;
use strict;
use Test::More tests => 7;
my $regex = qr/big\s*dog(*SKIP)(?!)|dog/;
unlike 'bigdog', $regex;
unlike 'big dog', $regex;
unlike 'big dog', $regex;
unlike 'cat', $regex;
like 'dog', $regex;
like 'small dog', $regex;
like 'medium dog and big dog', $regex;
qr/(?<!big)\s*dog/
is problematic as
big dog
^
|
matches here: is not preceded by "big" but "big "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With