The doc about the substitute function :h substitute()
tells us:
[...] the matching with {pat} is always done like the 'magic' option is set [...]
That's cool but what if I need to use substitute()
with another mode like say, verymagic or verynomagic? Is there a way to modify this behavior?
I guess a flag won't help me since the same doc topic says:
[...] When {flags} is "g", all matches of {pat} in {expr} are replaced. Otherwise {flags} should be "".
So here are my two questions:
- Is it possible to modify the magic mode used by
substitute()
? - If it is not possible, what is the most elegant/efficient way to perform a substitution on a string contained in a variable with another magic mode?