Re: Need Help with Change "Last, First" to "First Last"
Hello, On 10/29/06, Mike Blonder <[EMAIL PROTECTED]> wrote: >> Hi. >> >> I want to reorder variable2 and variable3 from the following line >> structure for 44 lines in a datafile, the data field separator is a >> "((" character >> >> variable1 data((variable2 data((variable3 data((variable4 data >> ((variable5 data((variable6 data((variable7 data((variable8 data >> ((variable9 data(( .. (( (end of line. some lines have upwards to 20 >> or more variables) >> >> to >> >> variable1 data((variable3 data((variable2 data(( etc >> >> when I use the following syntax (which I extrapolated from sec 12.2 >> of VIM manual, version 6.3): >> >> 6,50s;\(variable2.*\)((;\(variable3.*\);\2\1; >> > > Try using the following command: > > :6,50s;\(variable2.\{-}\)((\(variable3.\{-}\)((;\2((\1(( > Thanks, it works perfectly. Can you explain: why you changed .* to . and the function of {-} '*' is greedy and matches as many characters as possible. \{-} is non-greedy and matches as few characters as possible. For example, take the following single-line of text: The quick brown fox jumped over the fence. The quick brown fox jumped over the fence. If you use the following substitute command on the above text: :s/The.*fox/The dog/g The line will be changed to the following: The dog jumped over the fence. OTOH, if you use the following command: :s/The.\{-}fox/The dog/g The line will be changed to: The dog jumped over the fence. The dog jumped over the fence. - Yegappan > >> >> "variable3 data" is correctly moved into the position formerly held >> by "variable2 data". However, "variable2 data" is appended to the >> end of the entire line and NOT moved to the position that was >> formerly taken by "variable3 data" >> >> Any ideas as to what's wrong? >>
Re: Need Help with Change "Last, First" to "First Last"
Thanks, it works perfectly. Can you explain: why you changed .* to . and the function of {-} Thanks Mike On Oct 29, 2006, at 10:27 AM, Yegappan Lakshmanan wrote: Hi, On 10/29/06, Mike Blonder <[EMAIL PROTECTED]> wrote: Hi. I want to reorder variable2 and variable3 from the following line structure for 44 lines in a datafile, the data field separator is a "((" character variable1 data((variable2 data((variable3 data((variable4 data ((variable5 data((variable6 data((variable7 data((variable8 data ((variable9 data(( .. (( (end of line. some lines have upwards to 20 or more variables) to variable1 data((variable3 data((variable2 data(( etc when I use the following syntax (which I extrapolated from sec 12.2 of VIM manual, version 6.3): 6,50s;\(variable2.*\)((;\(variable3.*\);\2\1; Try using the following command: :6,50s;\(variable2.\{-}\)((\(variable3.\{-}\)((;\2((\1(( - Yegappan "variable3 data" is correctly moved into the position formerly held by "variable2 data". However, "variable2 data" is appended to the end of the entire line and NOT moved to the position that was formerly taken by "variable3 data" Any ideas as to what's wrong? Thanks Mike
Re: Need Help with Change "Last, First" to "First Last"
Hi, On 10/29/06, Mike Blonder <[EMAIL PROTECTED]> wrote: Hi. I want to reorder variable2 and variable3 from the following line structure for 44 lines in a datafile, the data field separator is a "((" character variable1 data((variable2 data((variable3 data((variable4 data ((variable5 data((variable6 data((variable7 data((variable8 data ((variable9 data(( .. (( (end of line. some lines have upwards to 20 or more variables) to variable1 data((variable3 data((variable2 data(( etc when I use the following syntax (which I extrapolated from sec 12.2 of VIM manual, version 6.3): 6,50s;\(variable2.*\)((;\(variable3.*\);\2\1; Try using the following command: :6,50s;\(variable2.\{-}\)((\(variable3.\{-}\)((;\2((\1(( - Yegappan "variable3 data" is correctly moved into the position formerly held by "variable2 data". However, "variable2 data" is appended to the end of the entire line and NOT moved to the position that was formerly taken by "variable3 data" Any ideas as to what's wrong? Thanks Mike
Need Help with Change "Last, First" to "First Last"
Hi. I want to reorder variable2 and variable3 from the following line structure for 44 lines in a datafile, the data field separator is a "((" character variable1 data((variable2 data((variable3 data((variable4 data ((variable5 data((variable6 data((variable7 data((variable8 data ((variable9 data(( .. (( (end of line. some lines have upwards to 20 or more variables) to variable1 data((variable3 data((variable2 data(( etc when I use the following syntax (which I extrapolated from sec 12.2 of VIM manual, version 6.3): 6,50s;\(variable2.*\)((;\(variable3.*\);\2\1; "variable3 data" is correctly moved into the position formerly held by "variable2 data". However, "variable2 data" is appended to the end of the entire line and NOT moved to the position that was formerly taken by "variable3 data" Any ideas as to what's wrong? Thanks Mike