Wednesday, June 20, 2012

Vim regex to find whitespaces between quotes

In this example we use the string href="test find white spaces" as an example and we want to encode our URIs with %(percent-encoding) in order to comply with RFC3986.
So we need to encode 'space' character to '%20'. In vim, we can do it simple enough with the following command :
:%s/\(href="[^"]\+\)\@<= /%20/g
been working almost 1 hour to figure this out. :p

Hope that helps somebody. (:

No comments:

Post a Comment

Feel free to comment all my posts.