help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining existence of text following point


From: tomas
Subject: Re: Determining existence of text following point
Date: Tue, 18 May 2021 14:35:42 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, May 18, 2021 at 02:23:25PM +0200, Christopher Dimech wrote:
> > Sent: Tuesday, May 18, 2021 at 11:56 PM
> > From: "Jean Louis" <bugs@gnu.support>
> > To: "Christopher Dimech" <dimech@gmx.com>
> > Cc: tomas@tuxteam.de, help-gnu-emacs@gnu.org
> > Subject: Re: Determining existence of text following point
> >
> > * Christopher Dimech <dimech@gmx.com> [2021-05-18 14:27]:
> > > > > (setq sa (string-match "[^[:blank:]]" "     "))
> > 
> > > I find the description different from what string-match actually
> > > returns.
> > 
> > The symbol ^ means "not following", and that regular expression means
> > match non-blanks.
> > 
> > (string-match "[^[:blank:]]" "     ") ⇒ nil
> > (string-match "[[:blank:]]" "     ") ⇒ 0
> 
> You are correct.  "^" means match everything but the following class.
> 
> I am quite used on see "^" to mean "beginning of line".  So just read
> it as I usually do.

This is outside the context of character classes, i.e. outside [...].

> It is unfortunate that there exist so many different syntaxes for writing
> regular expressions.

Yet all those syntaxes coincide in that one thing: "^" outside of
brackets means "anchor at the beginning" (of line, most of the time,
but it could be "of string" or similar), whereas inside of character
class brackets (but _only_ right after the opening bracket!) it
means complement.

This is an unfortunate quirk, but those notations are around since
the early 1970s, so that ship has sailed. Go and tell a phisicist
to use something else than the "uppercase L" for the Lagrangian.

The multitude of regular expression extensions and implementations
is an issue, yes, but a completely different one.

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]