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

Time:09-10

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 )

CodePudding user response:

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

CodePudding user response:

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 
  • Related