Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: non-greedy matching?



--- Adam Spiers <adam@xxxxxxxxxx> wrote:

> however the other two invocations are:
> 
>   ..... | perl -pe 's/%{.*?%}//g'

Does this do what you want:
... | sed 's/%{[^}]*%}//g'

It works here unless for some reason you have a closing curly bracket
in your escape sequence - assuming I've not missed something else. It
is fairly common to do [^..]* instead of .* when avoiding the effects
of greedy matching. What does the ? achieve in your perl regex?

It's a pity the col program isn't more powerful.

> They are done in order to strip control characters from a prompt so
> that its display width can be determined.  At first I thought that it
> would surely be easy to avoid this, but I still haven't come up with

I haven't looked at your prompt function but you might also consider
checking if you can get what you want with the ternary expression in
the prompt expansion as it can check how many characters have been
printed on the current line.

Oliver

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie



Messages sorted by: Reverse Date, Date, Thread, Author