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: Jean Louis
Subject: Re: Determining existence of text following point
Date: Tue, 18 May 2021 15:44:00 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

(setq sa (string-match "[^[:blank:]]" "  A neutrino is a fermion")) ⇒ 2

The above is because it is matching anywhere anything that is not
blank. If there is only blank character alternative it will not
match. It will be true if there is anything non-blank.

Manual section: (info "(elisp) Regexp Special")

‘[^ ... ]’
     ‘[^’ begins a “complemented character alternative”.  This matches
     any character except the ones specified.  Thus, ‘[^a-z0-9A-Z]’
     matches all characters _except_ ASCII letters and digits.

(setq sb (not (string-match "[^[:blank:]]" "  A neutrino is a fermion"))) ⇒ nil

The `not' will yield TRUE if there is blank only in the string. 

What I find really good is that blank is not just space as we know it,
it will recognize other space types as well.

It will work with:   EN SPACE
(string-match "[^[:blank:]]" " ") ⇒ nil

It will work with: EM SPACE
(string-match "[^[:blank:]]" " ") ⇒ nil

It will work with: THIN SPACE
(string-match "[^[:blank:]]" " ") ⇒ nil

It will work with: HAIR SPAICE
(string-match "[^[:blank:]]" " ") ⇒ nil

It will work with: FIGURE SPACE
(string-match "[^[:blank:]]" " ") ⇒ nil

It will work with: NO BREAK SPACE
(string-match "[^[:blank:]]" " ") ⇒ nil

It will work with: OGHAM SPACE MARK
(string-match "[^[:blank:]]" " ") ⇒ nil

And I guess with other possible spaces. 


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/




reply via email to

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