Replace a char in a String


I feel this is to simple but i can`t remove a char of a String.

i tried to use “replace” , but Ignition sends me an error “replace is not defined”,

i put this in an event and a script and is the same error.

this is my code: replace(MyString, anychar , “”)

i forgot something?


Where are you trying to do this?

Are you trying to write Jython code or an expression?

myString = 'TestxString'
print myString.replace('x', ' ')
Test String
1 Like

tried to inside of an event in a button.
after tried in a script and i call the script inside the event of the button

As @dkhayes117 example shows, replace is a method on the string, not a standalone command.

Don’t forget you can use the script console under tools. I sometimes find it easier to play around in the console rather than in a window or in a component.

thanks, i solved my problem.

Thanks kevin.Herron and witman