Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

replace in javascript

var str = "Please locate where 'locate' occurs!";

str.replace("locate", "W3Schools"); //replace only replace first match from string
str.replace(/LOCATE/i, "W3Schools"); // i makes it case insensitive
str.replace(/LOCATE/g, "W3Schools"); // g replace all matches from string rather than replacing only first
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #replace #javascript
ADD COMMENT
Topic
Name
3+1 =