Reputation: 95
what regex can i use using perl flavor, to find all those lines that don't start with the tag .
the text i have is more or less like this:
<english> text text text text.
<english> text text text.
text text text
i need to verify, that all lines start with and i want to see all of those that don't start with it.
what i have tried is :
^[^<english>].*$
(?!^<english>).*
(?<!<english>).*
.*(?!<english>).*
but non of those work.
can somebody please help me, and explain the provided regex? thanks.
Upvotes: 0
Views: 379
Reputation: 32189
You need to do it as:
^(?!<english>).*?$
with the g
and m
modifier
This matches those lines that do not start with <english>
Demo: http://regex101.com/r/xZ1xF4
Upvotes: 3
Reputation: 35198
You don't need any assertions, just do the test:
use strict;
use warnings;
while (<DATA>) {
if (/^<english>/) {
print "matches: $_";
} else {
print "no match: $_";
}
}
__DATA__
<english> text text text text.
<english> text text text.
text text text
Upvotes: 3