zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <zefram@fysh.org>
To: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
Cc: zsh-workers@sunsite.auc.dk
Subject: Re: matching flags (was: Re: Should we backup this change? RE: Modifier substitutions.)
Date: Thu, 13 Apr 2000 13:22:20 +0100 (BST)	[thread overview]
Message-ID: <E12fidZ-0000hQ-00@crucigera.fysh.org> (raw)
In-Reply-To: <200004131137.NAA14795@beta.informatik.hu-berlin.de> from Sven Wischnowsky at "Apr 13, 2000 01:37:56 pm"

Sven Wischnowsky wrote:
>Before I forget it... from the code in pattern.c it doesn't look too
>hard to support flags for the other special `gaps between characters'
>supported by some regexp systems (beginning/end of line/word). Would
>it be interesting enough to have them, too? Might be useful with
>parsing command outputs as in ${$(...)...} sometimes. (The definition
>of `word' might be a problem, of course...)

The more general solution would be to support user-specified anchors.
Word/line anchors can be defined in terms of lookahead/lookback assertions
(like Perl's (?!)).  Suppose we define anchors thus:

	(#A			indicates anchor
	   a			indicates looking ahead
	   b			indicates looking back
	    n			(optional) negates the anchor result
	     :			separates flags from pattern
	      <pattern>)	pattern to check for

Then a `beginning of line' anchor (matching at the start of the string
or after an embedded newline) could be implemented as

	(#Ab:(#s)|$'\n')

(in this case, the (#s) could be taken out of the anchor).  One reasonable
`beginning of word' anchor would be

	(#Abn:[a-zA-Z0-9_])(#Aa:[a-zA-Z0-9_])

(read as "there is a word character immediately ahead, but not one
immediately behind").  Of course, anyone that uses these anchors
frequently would put them into a parameter, so that they can be invoked
as $~bol, etc.

-zefram


      reply	other threads:[~2000-04-13 12:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-13 11:37 Sven Wischnowsky
2000-04-13 12:22 ` Zefram [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E12fidZ-0000hQ-00@crucigera.fysh.org \
    --to=zefram@fysh.org \
    --cc=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).