Tag Archives: Javascript

String replace in Javascript

Taking a note: Javascript String.replace([pattern], [replacement]) method replaces only first occurence of the matched pattern. To replace all occurences, you’ll need a “global” flag: var str = “ABCDEFGHABCD”; //some string alert(str.replace(/A/g), “I”); //replacing each appearance //of A with an I

Posted in Software Development | Tagged , | Leave a comment