xxxxxxxxxx
oldstring = 'I like Guru99'
newstring = oldstring.replace('like', 'love')
print(newstring)
xxxxxxxxxx
const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';
console.log(p.replace('dog', 'monkey'));
// expected output: "The quick brown fox jumps over the lazy monkey. If the dog reacted, was it really lazy?"
const regex = /Dog/i;
console.log(p.replace(regex, 'ferret'));
// expected output: "The quick brown fox jumps over the lazy ferret. If the dog reacted, was it really lazy?"
xxxxxxxxxx
# use of replace() method
string = "Join our community of top freelancers"
# replace "top" with "top 1%"
print(string.replace("top", "top 1%"))
# printing the original string
print(string)
xxxxxxxxxx
string = "Hey! What's up?"
characters = "'!?"
for x in range(len(characters)):
string = string.replace(characters[x],"")
print(string)
xxxxxxxxxx
df[column_name].replace([old_value1, old_value2, old_value3], new_value)