
If the g flag is set, the method replaces all matches in the string with the replacement string; otherwise it replaces only the first match it finds.
EXAMPLES
//replaces first match
//wasit a rat i saw
var s = 'was it a rat i saw'; alert(s.replace(/[ ]/, ''))
//replaces all matches
//wasitaratisaw
var s = 'was it a rat i saw'; alert(s.replace(/[ ]/g, ''))
No comments:
Post a Comment