Sunday, February 28, 2010

Re: Capturing group in regex

* 2010-02-28 01:42 (-0800), rameo wrote:

> Lets say I want to search all number [0-9] with regex and what to put
> a "_" sign after every number.
>
> Normally I can capture the group using $1 but this doesn't work in
> gvim.

In regexp replace strings you can use "&" to refer back to the whole
match or \1 to \9 to refer to submatches.

> :s%/[0-9]/$1_/g --> doesn't work.

Try this:

%s/[0-9]/&_/g

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment