I tried /^[^(xyz)]/ but I don’t trust it. I don’t think the grouping
will take inside the character class.
The [^(xyz)] creates a negative character class, so your regex would
match any string that started with a character not in the given set.
Not what you really want
Do I need a negative lookahead assertion?
That would be a simple solution: /^(?!xyz)/ which will match when
the beginning of the line/string is not followed by ‘xyz’.
I tried /^[^(xyz)]/ but I don’t trust it. I don’t think the grouping
will take inside the character class.
The [^(xyz)] creates a negative character class, so your regex would
match any string that started with a character not in the given set.
Not what you really want
Do I need a negative lookahead assertion?
That would be a simple solution: /^(?!xyz)/ which will match when
the beginning of the line/string is not followed by ‘xyz’.
Uhm, maybe I’ve misunderstood (wouldn’t be the first time) – I thought
you
wanted to match strings that did not begin with ‘xyz’ … and as far as
I
can tell, “29384723xyz02342” does not start with ‘xyz’.
while DATA.gets
print if ~/^(?!xyz)/
end END
xyefoo
xyzpfoo
asdfsdf
1230xyzasdf
Uhm, maybe I’ve misunderstood (wouldn’t be the first time) – I thought
you
wanted to match strings that did not begin with ‘xyz’ … and as far as
I
can tell, “29384723xyz02342” does not start with ‘xyz’.
while DATA.gets
print if ~/^(?!xyz)/
end END
xyefoo
xyzpfoo
asdfsdf
1230xyzasdf
Uhm, maybe I’ve misunderstood (wouldn’t be the first time) – I thought
you
wanted to match strings that did not begin with ‘xyz’ … and as far as
I
can tell, “29384723xyz02342” does not start with ‘xyz’.
while DATA.gets
print if ~/^(?!xyz)/
end END
xyefoo
xyzpfoo
asdfsdf
1230xyzasdf