squiblo Posted April 15, 2010 Share Posted April 15, 2010 the following code only seems to replace the first "&" but any "&"s after that are not changed for example.... if var poststr = my name is bob & i live in england (this works) but... if var poststr= my name is bob & i live in england & i like pizza (this does not work) var replaceAND = "and38"; var message = poststr.replace("&", replaceAND); alert(message); Link to comment https://forums.phpfreaks.com/topic/198679-javascript-replace/ Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 poststr.replace(/&/g, replaceAND); Link to comment https://forums.phpfreaks.com/topic/198679-javascript-replace/#findComment-1042634 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.