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

Caolan McNamara caolan at skynet.ie
Mon Oct 11 15:19:06 IST 2004


On Mon, 2004-10-11 at 13:15 +0100, Conor McDermottroe wrote:
> On Mon, 2004-10-11 at 12:53, John Tobin wrote:
> > 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.
> 
> $line !~ /^slot:/;
> 
> also works.

I appreciate the efforts, but its a classic regexp I'm looking for, so
perl extensions, or actual language logic to negate the regexp is out.
We'd be on the right track if the regexp was accepted by the regexp
search and replace in openoffice.org. But it doesnt' matter anyway, I
just had to come up with an inclusive regexp for some different artifact
of the strings in question, but was still interested if there was a way
to make my original thought work.

C.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.linux.ie/pipermail/ilug/attachments/20041011/738addfa/attachment.pgp


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