Whats the easiest way in javascript to replace ABC, DEF, GHI with XYZ in the following strings
http://z.site.com/z/ABC/z/z.html
http://z.site.com/z/DEF/z/z.html
http://z.site.com/z/GHI/z/z.html
Whats the easiest way in javascript to replace ABC, DEF, GHI with XYZ in the following strings
http://z.site.com/z/ABC/z/z.html
http://z.site.com/z/DEF/z/z.html
http://z.site.com/z/GHI/z/z.html
var url = "http://z.site.com/z/ABC/z/z.html";
url = url.replace(/ABC|DEF|GHI/, "XYZ");
You can use a regular expression to detect that pattern and change the three letters in question:
s = s.replace(/^http:\/\/z\.site\.com\/z\/.../, 'http://z.site.com/z/XYZ');