-1

I need a javascript code to extract number from string like "pushedProductType0".

1
  • I would use jQuery for this for sure!! Commented Jul 20, 2011 at 14:59

1 Answer 1

3
alert( "pushedProductType0".match(/\d/) )
Sign up to request clarification or add additional context in comments.

3 Comments

This will get the 1st number, and only single digits. You should do .match(/\d+/g)
I agree with /\d+/ but the global flag is not appropriate as it would return an array. This is just a starter for 10, the question is not specific enough to develop any further
Any hint on getting the last one ? Here's my question: stackoverflow.com/questions/11059054/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.