zsh-workers
 help / color / mirror / code / Atom feed
* Extending regexes
@ 2022-07-04 12:03 Sebastian Gniazdowski
  2022-07-04 13:47 ` Peter Stephenson
  2022-07-06 23:07 ` Phil Pennock
  0 siblings, 2 replies; 8+ messages in thread
From: Sebastian Gniazdowski @ 2022-07-04 12:03 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]

Hi,
Zsh has extensions to regular regexes - the ~ and ^ negations. They, as it
can be expected from negations that are required by Turing universal
machines, introduce a whole new universe of computations over standard
regular expressions. For example matching in an AND fashion:

If [[ ABC == *A*~^*B*~^*C* ]]; then
  print A,  B and C found
fi

I think that regexes look pretty limited from this point of view and that
pcre extensions went wrong path with the look forward and behind semantics.
The typical, common attempts of using regex [^] negation like [^(string)]
are simply there in zsh patterns as ^string.

I've recently used ~ negation in a project to reject a set of known tokens
from matching at given position with a great success to match a loose `for`
syntax in an zinit-annex-pull extension to zinit that greps and extracts
zinit commands from any web page. I cannot see it possible without the
extra negation.

Therefore I thought that it's weird that such an useful feature is missing
from the commonly used regex syntax. So maybe an attempt of updating it has
sense? Could someone experienced with them like Oliver prepare some white
papers to accomplish this? It would be a great event to extend the old
regexes with such a great feature like not one, but TWO new negations.

[-- Attachment #2: Type: text/html, Size: 1590 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-07  0:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 12:03 Extending regexes Sebastian Gniazdowski
2022-07-04 13:47 ` Peter Stephenson
2022-07-04 19:15   ` Bart Schaefer
2022-07-04 19:41     ` Peter Stephenson
2022-07-06 10:03       ` Daniel Shahaf
2022-07-06 18:40   ` stephane
2022-07-06 23:07 ` Phil Pennock
2022-07-07  0:22   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).