zsh-users
 help / color / mirror / code / Atom feed
* convert sed to zsh
@ 2015-11-26 17:49 Ray Andrews
  2015-11-26 20:17 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Ray Andrews @ 2015-11-26 17:49 UTC (permalink / raw)
  To: Zsh Users

I'm trying to convert a 'sed' filter to native zsh.  Here's the sed:

     bar=$( echo $foo |
     sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" )

Here's my candidate zsh:

     bar=$foo//$'\x1B'\[([0-9](#c0,2)(;[0-9](#c0,2))#)#[mGK]/}

... so far it's working, but I'm nervous about it.  In another context 
it seems I have to backslash the semi-colon, but here it seems ok either 
way, but of course it should be one or the other. The 'sed' is of course 
the kosher way (I believe) of removing color codes and various other 
escapes like "\e[K" that seem to hang around colorized output of 'grep' 
and so on.  With several different forms of color codes, I want to be 
sure I get this right. Unless of course zsh already has a stock way of 
stripping escape sequences, which it very well might.


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

end of thread, other threads:[~2015-11-26 21:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26 17:49 convert sed to zsh Ray Andrews
2015-11-26 20:17 ` Bart Schaefer
2015-11-26 21:18   ` Ray Andrews

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).