[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to replace multiple char from string and substitute new char

On Thu, Oct 12, 2017, Iranna Mathapati wrote:

>Hi Team,
>How to replace multipal char from string and substitute with new char with
>one line code
>str = "9.0(3)X7(2) "  ===========>  9.0.3.X7.2
>need to replace occurrence of '(',')' with dot(.) chars
> 9.0.3.X7.\

My first gut response was to key on the words "replace" and "string"
and think there is a very handy method already existing that can
help with that.   It would be one line of code, if you don't mind having
wo function calls in that one line of code.

If you want only one function call and you want to do even more
substitutions than just those below, there is another handy functionin the
string object that can do so very nicely.

What did you try?

Roger Christman
Pennsylvania State University