Javascript string replace
Didn't know Javascript had regular expression support.
var str = "abcabc";will print "abcabc".
str.replace("a", "#");
document.write( str );
var str = "abcabc";will print "#bcabc".
document.write( str.replace("a", "#") );
var str = "abcabc";will print "#bc#bc".
document.write( str.replace(/a/g, "#") );
var str = "ABCABC";will print "#BCABC".
document.write( str.replace(/a/i, "#") );
var str = "ABCABC";will print "#BC#BC".
document.write( str.replace(/a/gi, "#") );
No comments:
Post a Comment