You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

正则表达式需求:匹配不含19/20开头四位年份的括号内容

解决方案:移除文件名中非年份类括号内容

直接用下面这个正则表达式匹配需要删除的冗余内容,将匹配结果替换为空字符串即可:

\s*\((?!(19|20)\d{2}\))[^)]*\)\s*

正则规则拆解(给完全不懂正则的你):

  • \s*:匹配括号前后的任意空格(不管有几个空格,甚至没有空格都能覆盖)
  • \(:精准匹配左括号(
  • (?!(19|20)\d{2}\)):核心判断——排除年份格式,意思是只要括号里是19XX或20XX这种四位数字,就不会被匹配
  • [^)]*:匹配括号里除了右括号)之外的所有内容(就是feat、编号这类冗余信息)
  • \):精准匹配右括号)

实际效果示例:

原文件名:

Abel the Kid - a Piece of My Love (feat. Snoop Dogg)
Alex Gaudino feat. Maxine Ashley - I'm in Love (I-039-M)
56K feat. Bejay - Save a Prayer (2003)
Mariah Carey feat. Trey Lorenz - I'll Be There (2012)
Savage Garden - To the Moon and Back (1997)

处理后文件名:

Abel the Kid - a Piece of My Love
Alex Gaudino feat. Maxine Ashley - I'm in Love
56K feat. Bejay - Save a Prayer (2003)
Mariah Carey feat. Trey Lorenz - I'll Be There (2012)
Savage Garden - To the Moon and Back (1997)

内容的提问来源于stack exchange,提问作者trejder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 14:45:58