[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