Version: v0.5.1 - Beta.  We welcome contributors & feedback.  THanks!

String.replace

replace(find, replace, limit = -1)

Description

Perform a substitution.

find can be a Regex pattern r'...' or a String.

'abc 123'.replace(r'(\d+)', 'xyz');
//= 'abc xyz'

'abc 123'.replace('123', 'xyz');
//= 'abc xyz'

'abcdef'.replace(r'\w', 'X', 4);
//= 'XXXXef'

See Also