0

I have URLs that are:

www.letters.com/letters/numbers/letters" 

and

www.letters.com/letters/letters/numbers/symbols

How can I extract just the group of consecutive numbers?

3
  • you mean this \d+ ? Commented Sep 15, 2014 at 17:22
  • What group of consecutive numbers..? Commented Sep 15, 2014 at 17:22
  • @AvinashRaj maybe...I am not very familiar with regex with jquery. How would I write a function to grab the current url and return the numbers? Commented Sep 15, 2014 at 17:26

1 Answer 1

1

Something like this?

var r = 'www.foo.com/bar/12345/foobarbaz'.match(/\d+/);
if (r)
    console.log(r[0]) //=> 12345
Sign up to request clarification or add additional context in comments.

Comments

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.