我想要正则表达式搜索和替换如下:
- 输入字符串以
images,videos,结尾friends- 输出字符串包含匹配的后缀
- 别的
- 输出字符串包含后缀
profile
- 输出字符串包含后缀
示例输入/输出:
/john-smith-images->/user-images/john-smith-videos->/user-videos/john-smith->/user-profile
我尝试了这个捕获后缀(如果存在)的正则表达式:
/.+?(images|videos|friends)?$/
我仅限于一种正则表达式和仅正则表达式的解决方案。我需要在 mod_rewrite/IIRF/IIS URL 重写中使用它。