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.
精彩评论