Ollifi Posted October 29, 2010 Share Posted October 29, 2010 Hi, i started to play with JS replace function today.....but got problemsplease go to this address http://www.dealextreme.com/forums/Forums.d...threadid.739338 and write this to browser addressbar java script:var sku=location.href;sku.replace("http:/www.dealextreme.com/forums/Forums.dx/Forum", "");sku.replace("/~~threadid.[0-9]/i", "");alert(sku); I tried with firefox & Chrome but they both output a alert with text http://www.dealextreme.com/forums/Forums.dx/Forum.24~threadid.739338 text should be 24 hopefully you could help me..thx! Link to comment Share on other sites More sharing options...
aspnetguy Posted October 29, 2010 Share Posted October 29, 2010 try this ava script:var sku=location.href;sku=sku.replace("http:/www.dealextreme.com/forums/Forums.dx/Forum", "");sku=sku.replace("/~~threadid.[0-9]/i", "");alert(sku); Link to comment Share on other sites More sharing options...
justsomeguy Posted October 29, 2010 Share Posted October 29, 2010 Check the characters in your URL. Your pattern to look for the numbers will also want to specify "1 or more", right now you're looking for only 1 digit following the dot (the dot probably needs to be escaped also, but probably won't matter). You also have 2 tildes in the second pattern. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.