in reply to Re: String Manipulation
in thread String replace, another question

That regex does not preserve the <bindpass> tags and will replace the password in any case, not only when it is "welcome1".

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^3: String Manipulation
by ikegami (Patriarch) on Aug 27, 2011 at 05:02 UTC
    Fixed the first. The second was intentional. (It's not clear whether he wants "to change the password that is 'welcome1' in the example" or if he wants "to change the password if it is 'welcome1'. I think the former is more likely, but you subscribe to the latter interpretation.)
      Indeed, the OP's specs are not entirely clear. Just like in real life!

      I have seen in a number of applications that "welcome1" is some kind of default password, so he may want to check only these and leave the "real" user passwords alone.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James