Re: repeat replace many time on each line

2007-04-03 Thread Arnaud Bourree


Tobia wrote on 02/04/2007 23:51:
 Bob Hiestand wrote:
 Tobia wrote:
 Arnaud Bourree wrote:
 I've Xml document with attribute likes:
 foo=00 12 AF
 I want to replace with:
 foo=0x00 0x12 0xAF
 this works:

 %s/\%(\%(foo=\\)\@=\%([0-9A-F]\{2\}\s\)*\)\@=\([0-9A-F]\{2\}\)/0x\1/g
 In using :s with the /g flag, I take it the potential changes are
 marked first, and then executed, per line?
 
 It would seem so.
 
 By the way, I would have used a simpler pattern for such a task:
 
 %s/\v%(foo\=[^]*)@=(\x\x)/0x\1/g
Thanks that is exactly what I expect: it works for all values listed in
foo attribute. I don't need to repeat the command.
Good lesson for me today: keep it simple ;-)
 
 
 I prefer when dealing with that many special characters to use the
 very-magic form
 
 Me too.  I can't stand trying to match \( \) with my eyes, they just
 don't look right, not to mention \{ \? \+...  Egrep and Perl have it
 right.  I wish I could turn very-magic on by default.
 
 
 Tobia
 

-- 
Reclaim Your Inbox!
http://www.mozilla.org/products/thunderbird


repeat replace many time on each line

2007-04-02 Thread Arnaud Bourree
Hello,

I've Xml document with attribute likes:
foo=00 12 AF
I want to replace with:
foo=0x00 0x12 0xAF

I try:
%s/\%(\%(foo=\\)\@=\%(0x[0-9A-F]\{2\}\s\)*\)\@=\([0-9A-F]\{2\}\)/0x\1/g

It works fine for each first occurrence of each line but not on others
whatever I've put g option.
I have to use repeat manually until change is finish.

How can I do repeat?

Thanks,

Arnaud.

-- 
Reclaim Your Inbox! http://www.mozilla.org/products/thunderbird


Re: repeat replace many time on each line

2007-04-02 Thread Bob Hiestand

On 4/2/07, Tobia [EMAIL PROTECTED] wrote:

Arnaud Bourree wrote:
 I've Xml document with attribute likes:
 foo=00 12 AF
 I want to replace with:
 foo=0x00 0x12 0xAF

 %s/\%(\%(foo=\\)\@=\%(0x[0-9A-F]\{2\}\s\)*\)\@=\([0-9A-F]\{2\}\)/0x\1/g

this works:

%s/\%(\%(foo=\\)\@=\%([0-9A-F]\{2\}\s\)*\)\@=\([0-9A-F]\{2\}\)/0x\1/g


In using :s with the /g flag, I take it the potential changes are
marked first, and then executed, per line?

Somewhat more generally, the pattern above could be:

%s/\%(\%(foo=\\)\@=\%(\%(0x\)\?[0-9A-F]\{2\}\s\)*\)\@=\([0-9A-F]\{2\}\)/0x\1/g

which works both with and (repeatedly) without the /g flag.

I prefer when dealing with that many special characters to use the
very-magic form:

%s/\v%(%(foo\=)@=%(%(0x)?[0-9A-F]{2}\s)*)@=([0-9A-F]{2})/0x\1/g

... but that's obviously a matter of personal preference.

Thank you,

bob


Re: repeat replace many time on each line

2007-04-02 Thread Tobia
Bob Hiestand wrote:
 Tobia wrote:
  Arnaud Bourree wrote:
   I've Xml document with attribute likes:
   foo=00 12 AF
   I want to replace with:
   foo=0x00 0x12 0xAF
 
  this works:
 
  %s/\%(\%(foo=\\)\@=\%([0-9A-F]\{2\}\s\)*\)\@=\([0-9A-F]\{2\}\)/0x\1/g

 In using :s with the /g flag, I take it the potential changes are
 marked first, and then executed, per line?

It would seem so.

By the way, I would have used a simpler pattern for such a task:

%s/\v%(foo\=[^]*)@=(\x\x)/0x\1/g


 I prefer when dealing with that many special characters to use the
 very-magic form

Me too.  I can't stand trying to match \( \) with my eyes, they just
don't look right, not to mention \{ \? \+...  Egrep and Perl have it
right.  I wish I could turn very-magic on by default.


Tobia