Loading ...
Sorry, an error occurred while loading the content.

Re: Replacing a character in a string

Expand Messages
  • Spiros Bousbouras
    ... That s much better. You can even do echo s[-3:-1] which gives rty. I wonder what is the purpose of the strpart() function when such a convenient notation
    Message 1 of 5 , Apr 2, 2009
    • 0 Attachment
      On 2 Apr, 17:14, Maxim Kim <haba...@...> wrote:
      > On 2 апр, 19:34, Spiros Bousbouras <spi...@...> wrote:
      >
      > > let s = 'qwerty'
      > > Let's say I want to replace the first character by Q. I thought
      > > the following would work
      > > let s[0] = 'Q' but it gives
      > > E689: Can only index a List or Dictionary
      > > So what is the simplest way to achieve such a task ?
      > ...
      > > Anyone got a better idea ?
      >
      > let s='qwerty'
      > let s='Q'.s[1:]

      That's much better. You can even do echo s[-3:-1] which
      gives rty. I wonder what is the purpose of the strpart()
      function when such a convenient notation exists.

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.