-1

I have a simple line of code that gets me the current path location using AngularJS :

$location.path()

Which results in the following format: /stringValue/intValue/stringValue for example - test/1234/testing

What would be the simplest way to extract the intValue from what $location.path() returns?

1
  • 1
    What about $location.path().split('/')[1]? Commented Jul 24, 2017 at 21:49

1 Answer 1

1

This will extract numbers from you url:

var r = /\d+/;
var s = "/string/12345/string2";
alert (s.match(r));

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.