René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
replace [JavaScript snippet] | ||
function main() { var str = "fourty-two: 42"; var rep = str.replace('42', 'FOURTY-TWO'); txt_out(rep); rep = str.replace(/o/, 'X'); txt_out(rep); rep = str.replace(/o/g, 'X'); txt_out(rep); rep = str.replace(/[aeiou]/g, 'X'); txt_out(rep); rep = str.replace(/(\w)/g, '$1$1'); txt_out(rep); rep = str.replace(/(\d)/g, function(s) {return parseInt(s)+1;}); txt_out(rep); }
See also other Javascript snippets
|