Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python String Replace

string = "Welcome to Softhunt website, Softhunt is a website dedicated to programming courses"

print("Original String  :", string)
# replacing 'courses' with 'tutorials'
print("Replaced String: ", string.replace("courses", "tutorials"))
# replacing only 2 occurences of 'Softhunt'
print("Replaced with 2 occurences: ",string.replace("Softhunt", "Softhunt.net", 2))
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #String #Replace
ADD COMMENT
Topic
Name
2+2 =