开发者

RegEx to replace trailing underscore with number of a string

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜