Using substitute on a variable

See :help substitute of :help substitute().

It is the counterpart of the substitute command (See :help :substitute).

substitute({expr}, {pat}, {sub}, {flags})       *substitute()*

    The result is a String, which is a copy of {expr}, in which
    the first match of {pat} is replaced with {sub}.  This works
    like the ":substitute" command (without any flags).  But the
    matching with {pat} is always done like the 'magic' option is
    set and 'cpoptions' is empty (to make scripts portable).
    'ignorecase' is still relevant.  'smartcase' is not used.
    See |string-match| for how {pat} is used.
    And a "~" in {sub} is not replaced with the previous {sub}.
    Note that some codes in {sub} have a special meaning
    |sub-replace-special|.  For example, to replace something with
    "\n" (two characters), use "\\\\n" or '\\n'.
    When {pat} does not match in {expr}, {expr} is returned
    unmodified.
    When {flags} is "g", all matches of {pat} in {expr} are
    replaced.  Otherwise {flags} should be "".
    Example: >
        :let &path = substitute(&path, ",\\=[^,]*$", "", "")
    This removes the last component of the 'path' option. 
        :echo substitute("testing", ".*", "\\U\\0", "")
    results in "TESTING".

In your example I guess that
let l:bar = substitute(l:bar, "world", "kitten", "") should work

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)