* matching flags (was: Re: Should we backup this change? RE: Modifier substitutions.)
@ 2000-04-13 11:37 Sven Wischnowsky
2000-04-13 12:22 ` Zefram
0 siblings, 1 reply; 2+ messages in thread
From: Sven Wischnowsky @ 2000-04-13 11:37 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> You should now be able to do ${foo/(#s)$bar(#e)/...}.
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...)
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: matching flags (was: Re: Should we backup this change? RE: Modifier substitutions.)
2000-04-13 11:37 matching flags (was: Re: Should we backup this change? RE: Modifier substitutions.) Sven Wischnowsky
@ 2000-04-13 12:22 ` Zefram
0 siblings, 0 replies; 2+ messages in thread
From: Zefram @ 2000-04-13 12:22 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-04-13 12:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-13 11:37 matching flags (was: Re: Should we backup this change? RE: Modifier substitutions.) Sven Wischnowsky
2000-04-13 12:22 ` Zefram
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).