Jump to content
Sign in to follow this  
Ollifi

Replace problem

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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);

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...