LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] regexp to match anything except a line that starts with something specific

[ILUG] regexp to match anything except a line that starts with something specific

John Tobin tobinjt at netsoc.tcd.ie
Mon Oct 11 12:53:16 IST 2004


On Mon, Oct 11, 2004 at 09:46:44AM +0000, Caolan McNamara wrote:
> I'm trying to make a regexp which will match any line except a line that
> starts with "slot:" I've got ^([^s]|s[^l]|sl[^o]|slo[^t]|slot[^:]).*
> which matches any line that doesn't have "slot:" in it, but lines that
> don't start with "slot:" but nevertheless contain it are still matched
> by the regexp. Any ideas ? It's got to be a regexp for other
> constraints.

Perl has a very nice negative lookahead feature:
m/^(?!slot:)/
will match any line not starting with slot:.
perldoc perlre has more details.

-- 
John Tobin
"Windows seems to take the position that since things in the kernel
are defined as secure, you should put everything in the kernel.  When
they can't figure out how to secure something, they just put it in the
kernel and define it as secure."    -- Bruce Schneier, Secrets and Lies



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell