Find the last number in the string. A number from 1. A string can end in a number or slash. The response should be only 1 item.
Source line can be:
- " http: // domen: 8000 / one / two / tree / 123456789 / "
- " http: // domen: 8000 / one / two / tree / 123456789 "
- " http: // domen: 8000 / one / two / tree / 1 "
- " http: // domen: 8000 / one / 123 / two / 1234567890123456789 / "
Result
- 123456789
- 123456789
- one
- 1234567890123456789
My regular expression options
- / (?: /) (\ d +) (?: /)? $ /
- (?: /) \ d + (?: /)? $
Result
- / 123456789 /, 123456789 - 2 elements, only one is needed: 123456789
- / 123456789 / - 1 item, but slashes come in response, you need without them