Re: Problems with searching using regular expressions

Neil Hodgson <[email protected]> Sun, 3 Mar 2024 13:56:06 -0800 (PST)
Newsgroups gmane.editors.scite.general
Message-ID <[email protected]>
Some regular expression libraries have a flag for not matching the empty 
string at start which could be a direction here.

PCRE (from https://www.pcre.org/original/doc/html/pcreapi.html):

  PCRE_NOTEMPTY
An empty string is not considered to be a valid match if this option is 
set. If there are alternatives in the pattern, they are tried. If all the 
alternatives match the empty string, the entire match fails. For example, 
if the pattern
  a?b?
is applied to a string not beginning with "a" or "b", it matches an empty 
string at the start of the subject. With PCRE_NOTEMPTY set, this match is 
not valid, so PCRE searches further into the string for occurrences of "a" 
or "b".

  PCRE_NOTEMPTY_ATSTART
This is like PCRE_NOTEMPTY, except that an empty string match that is not 
at the start of the subject is permitted. If the pattern is anchored, such 
a match can occur only if the pattern contains \K.

   Neil

-- 
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scite-interest/cd539869-668e-4b0f-9159-8c6e2f3abe32n%40googlegroups.com.