ivan budiselic wrote:
>>> So, for the line:
>>>
>>> 1234 a a "a" a
>>>
>>> I'd like to get:
>>>
>>> 1234 b b "a" b
>>>
>>> The question is, is this possible and how.
>>>
>>> What I've tried is
>>> let line = substitute(line, '\([^\"]\{-}\)a', "\\1b", "g")
>>
>> ...because \{-} matches also 0 times; what you wanted is \{-1,}:
>>
>> let line = substitute('123 a "a" a', '\([^"]\{-1,}\)a', '\1b', 'g')
>>
> 
> Ok, this worked pretty well, except that it doesn't work for cases when
> there's an 'a' at the start of the line (which I might be able to fix), and

Allow matching 'start-of-line' (^) in front of 'a', too; see below.

> the other problem which I wasn't specific enough about, and that is that I'd
> like the change to happen to 'a's outside of strings, so for example
> "xxxaxxx" shouldn't match. I guess this changes things quite a bit, sorry
> for not being clear enough.

So, would you like further help? If yes, could you provide an example for what
you want to achieve?

s/\(^\|\s\)\zsa\ze\s\?/b/
works for
a 123 a a "xxxxaxxx" a
==>
b 123 b b "xxxxaxxx" b

-- 
Andreas.

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

Reply via email to