Reputation: 185
Can you please suggest regular expression for my URL. I am trying to parse a URL that is supposed to have only digits after the last trailing slash:
http://localhost/myproj/myservice/api/v4/lists/45678333
When I try this regular expression:
(http|https)://([A-z0-9|\.|\-]*)/myproj/myservice/api/v([.\d{1}])/lists/(.\d+$)
It is also accepting a45678333
as the last number. I just wanted to be a number of any length.
How do I form the regular expression that matches the number (and only a number) after the last slash?
Upvotes: 0
Views: 690
Reputation: 1597
Try this regular expression, it will help you out:
(http|https):\/\/([A-z0-9|.|-]*)\/myproj\/myservice\/api\/v([.\d{1}])\/lists\/(\d+$)
Upvotes: 0
Reputation: 42017
/(.\d+$)
matches a /
, then any single character followed by any number of digits at the end.
To match only digits at the end, you need:
/\d+$
If you want to capture the digits in a group:
/(\d+)$
Upvotes: 1