(imported topic written by boerio)
If I want to iterate through the lines of a file that don’t match particular text, such as ^# (lines starting with a ‘#’ character), how do I go about it? I can get the lines that I don’t want pretty easily, but for some reason can’t seem to grok how to get the lines I
do
want.
lines starting with “#” of file “foo”
That works pretty nicely. But I’m beating my head against a wall trying to get the lines that don’t match that pattern.
Maybe it’s because it’s 5pm and I’ve been doing this all day. Maybe some wine will help.
Thanks,
Jeff
(imported comment written by SystemAdmin)
If that doesn’t do it you might try ‘The BigFix’: http://support.bigfix.com/cgi-bin/kbdirect.pl?id=280
Here’s the relevance I came up with, you can still drink your wine though!
lines whose (it does not start with “#”) of file “foo”
(imported comment written by boerio)
Nice, Tyler!
I guess I should be a little more specific. I have a text file that has allowable entries
xx1
xx2
xx3
xx4
xx5
xx6
xx7
xx8
xx9
xx10
yy1
yy2
yy3
yy4
yy5
…
But xx11 isn’t allowed (neither is yy11). I was hoping that a regex call would work nicely. Something where I could match the exclusion of "xx
0-9
|xx10|yy
0-9
|yy
10
"
Jeff
(imported comment written by jessewk)
This should do it. Note that I had to add an end of line check $. Your expression matched on just the first 3 characters so anything that started with xx or yy followed by at least one digit would match.
Q: lines whose (not exists match (regex “xx0-9$|xx10$|yy0-9$|yy10$”) of it) of file “C:\documents and settings\administrator\desktop\test.txt”
A: xx11
A: yy11
Evaluation time: 0.922 ms
Evaluates to plural object of type file line
My sample file:
xx1
xx2
xx3
xx4
xx5
xx6
xx7
xx8
xx9
xx10
yy1
yy2
yy3
yy4
yy5
xx11
yy11
1 Like
(imported comment written by boerio)
Perfect! Thanks.
Jeff