View Full Version : javascript trouble string function

05-23-2006, 12:31 PM
Have a nice day ! I have this folowing code and it won't run? I can't understand why, pls help me solve this thanks.

I have a string, and I need to use match (to retrieve what i need) and use substr or replace (to replace my signs)

var orgstring = "!u!http://annt/newspage/media/stories/jerryc_canonrock.wmv!u!!w!300!w!!h!60!h!!s1!false!s1!!s2!true!s2!!s3!false!s3!";
var urlthis = orgstring;

urlthis = urlthis.match(/!u!(.*?)!u!/g);
urlthis = urlthis.replace("!u!",'');

I tried to use match and replace alone -> it runs. But use both -> it did'nt word.
What can I do ? pls

05-23-2006, 05:20 PM

returns an array of strings, so when you do this:

urlthis = urlthis.match(/!u!(.*?)!u!/g);

urlthis is now an array, which doesn't have a replace function, so this:

urlthis = urlthis.replace("!u!",'');


There's no reason to do match before replace. Try just using replace.