Fill
Fill

Reputation: 545

Regex: match text after specific symbol combination until the end of the word

I have something like that

test/pull/1
test/pull/2

My goal is to grab

1
2

Closest I got is this, any help appreciated:

(?<=pull\/\s)(\w+)

Upvotes: 0

Views: 400

Answers (2)

willy
willy

Reputation: 473

You can simply use this one:

([^\/]+$)

or if you are expecting non-digit characters:

(?<=pull\/).*$

And as mentioned in the comments, the .* will match till the end of the string, which might be too much. Even better:

(?<=pull\/)\w+

Upvotes: 1

Michael Halim
Michael Halim

Reputation: 728

test/pull/([0-9]{1,})

if test/pull/ is your unique identifier

pull/([0-9{1,}])

if your pull is your unique identifier

test/pull/([0-9a-zA-Z]{1,})

if your try to capture alphanumeric more than 1

([0-9a-zA-Z]{1,})$

if you don't know what your unique identifier is but you know it's always in the end of the word, and the text is alphanumeric

Upvotes: 2

Related Questions