Misbehavior in regular expression in VIM

Posted by poissonbreaker on Super User See other posts from Super User or by poissonbreaker
Published on 2012-10-14T08:23:47Z Indexed on 2012/10/14 9:40 UTC
Read the original article Hit count: 160

Filed under:
|

I am having a problem with a regular expression on vim. I have a pattern as follows: http:\/\/\(\w\+\.\?\)\+ [matches http://(AS MANY WORDS FOLLOWED BY DOT OR NOT ENCOUNTERS) e.g. http://wd1.wd2.com]

I have a text as follows:

http://wd1.wd2.com/wd3

I am trying to make this substitution on it:

s/\(http:\/\/\)\(\w\+\.\?\)\+/\1wd4.wd5.com

and the result is http://wd4.wd5.com /wd3 (Notice the white space inserted at the end of the replacement)

How can I avoid having this inserted space? I am afraid is a bug in the regexp engine but I am not sure.

© Super User or respective owner

Related posts about vim

Related posts about regex