magelor wrote at Fri, 25 Jul 2003 11:09:03 +0200: > /tmp/test/.test.txt > /tmp/test/hallo.txt > /tmp/test/xyz/abc.txt > /var/log/ksy/123.log > > > now i need a regex that matches all lines but the one that contains a > filename starting with a point. like ".test.txt". how can i do that? > > this is what i have: > > '\.(?!tgz)[^.]*$' this matches everything, but tgz at the end of a > line, so > > '(?!\.)[^.]*$' should do the job, but it doesnt:(....
If you only want to guarantuee that the base filename doesn't start with a dot, you might try something like m!/(?!\.)\w+\.\w+$! # or m!/[^.]+\.\w+$! # or m!/[^/.]+$! The first both checks wether there is a *.* file (with no leading \.) after the last slash. The second checks whether the string ends on a sequence of no slashes and no dots what also does what you might want. However, in general I would propose to use a module to gain an easy understandable and robust solution: use File::Basename; # available in CPAN sub is_file_starting_with_dot { return basename($_[0]) =~ /^\./; } foreach ("/tmp/test/.test.txt", "/tmp/test/hallo.txt", "/tmp/test/xyz/abc.txt", "/var/log/ksy/123.log", ) { print $_, is_file_starting_with_dot($_) ? " starts with dot" : " :-) "; print "\n"; } Best Wishes, Janek PS: It's better not to shout to the reader with an uppercase subject that isn't very detailed. I would have ignored you if it wouldn't be friday :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]