Tuesday, August 25, 2009

RE: Regex help

>and I want to copy the data of third field to the last field, like this
>03;14;Production;trombetas;Xeon;RHEL;-;PPE;-;F1-A0.3;|trombetas

Use fields denoted by a "\(" and "\)" to copy/move what you want, eg,

:g/\([^;]*;[^;]*;\)\([^;]*\)\(;.*\)/s//\1\2\3\2/

to break it up to

<field1><field2><field3> ("field2" is what you want to
copy to the end)

and turn it into

<field1><field2><field3><field2>

and in this case "field1" is [0/more not semis + semi], field2 (which
you want to copy) is [0/more not-semis], followed by field3 which is
[semi + 0/more anything to the end of the line], and copying field2 to
the end.

Did that make any sense?

For help, dial up

:h \(\)

and go crazy...

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments: