简体   繁体   中英

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+)
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

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+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM