<div dir="ltr"><br><br><div class="gmail_quote">On Sun, Jun 27, 2010 at 10:52 PM, Oron Peled <span dir="ltr"><<a href="mailto:oron@actcom.co.il">oron@actcom.co.il</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
First a short answer to Guy -- 'col -b' won't help because it removes the<br>
meta sequences of backspaces (that's what the 'b' stands for) used in<br>
Unix/Linux manuals (cat pages FWIW). These sequences were used as a<br>
neutral format that is later translated to terminal specific escape<br>
sequences by programs such as more/less etc.<br>
<div class="im"><br>
On Sunday, 27 בJune 2010 12:08:09 Erez David wrote:<br>
> s/\e[\[01]m//g does't do the job. since the first [ is not a real character<br>
> it is a meta character...<br>
<br>
</div>Not exactly. The sequences presented are part of ANSI standard of escape<br>
sequences used to highlight text (bold/underline/etc) on terminals.<br>
So we don't talk about a special character, but a special *strings*.<br>
<br>
All these sequences have a common form. The simplest format is:<br>
<br>
<ESCAPE>[<numeric_code>m<br>
<br>
The ASCII code of ESC (decimal 27 as mentioned by someone else here) is<br>
commonly written as ^[ (control+left bracket) because this is actually<br>
the ASCII number of this character.<br>
<br>
BTW: if the escape key in your keyboard is broken, you can use control+left<br>
bracket as a substitute because it is really the same character.<br>
<br>
The result of this is that when writing the sequence as text, it is often<br>
presented as: ^[[2m<br>
<br>
But note that the first bracket is part of "control+bracket" which simply<br>
means the escape character, and the second bracket is the real '['<br>
character which is part of the sequence (the length of the example above<br>
is exactly 4 characters)<br>
<br>
Now you should see the problem with your regex -- the '[' in a regex means<br>
open a character class.... so it is special character for regex.<br></blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">A correct regex should be:<br>
s/\e\[\d+m//<br>
But this also has an error because it's greedy. Let's fix it:<br>
s/\e\[\d+?m//<br>
<br></blockquote><div>Well, he said</div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><span class="Apple-style-span" style="font-size: 13px; "> s/\e[\[01]m//g</span></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><span class="Apple-style-span" style="font-size: 13px; "><br></span></span></font></div><div>
<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">And I thought he actually ment</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "> s/\e\[[01]m//g</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; ">which is just a minor typo and should actually capture the examples given by the original poster.</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">(Well, I'm no expert shlomifologist---it just seemed a more probable explanation...) :-)</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"> AA</span></font></div>
</div></div>