开发者

RegEx to replace trailing underscore with number of a string

开发者 https://www.devze.com 2023-04-09 12:38 出处:网络
I have an ID that looks like this: prefix_my-awesome-slug_123 Now I wou开发者_如何学Gold like to have a regular expression that removes the underscore and number on the end (_%d).for perl like regex

I have an ID that looks like this: prefix_my-awesome-slug_123

Now I wou开发者_如何学Gold like to have a regular expression that removes the underscore and number on the end (_%d).


for perl like regex implementations this should do it:

s/_\d+$//


/_[0-9]+$/ - easy. Just replace the match with an empty string.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号