Replace 记事本++;双括号中的子表达式的regexp ID

Replace 记事本++;双括号中的子表达式的regexp ID,replace,expression,notepad++,Replace,Expression,Notepad++,我试图在记事本++中找到如下字符串: '<a href="/mp3files/cards/Sentence With any Number of Words.mp3"></a>', 或另一种方法: (cards/)([^\s]{1,50})([\s\.\?\!\-\,]{0,})([^\s]{1,50}) 这两个都可以搜索,但我找不到替代品。 问题是一个句子中的字数可能不同。 我无法得到双括号中的子表达式的ID 以下替换格式:\1\2\3…不起作用

我试图在记事本++中找到如下字符串:

'<a href="/mp3files/cards/Sentence With any Number of Words.mp3"></a>',
或另一种方法:

(cards/)([^\s]{1,50})([\s\.\?\!\-\,]{0,})([^\s]{1,50})
这两个都可以搜索,但我找不到替代品。 问题是一个句子中的字数可能不同。 我无法得到双括号中的子表达式的ID

以下替换格式:
\1\2\3…
不起作用,因为我无法获得双括号中子表达式的正确ID。
我试图用谷歌搜索这个主题,但什么也找不到。非常感谢任何建议、链接或最好的完整替换表达式。

这将用连字符和小写文件名替换
/cards/
之后的所有空格


  • Ctrl+H
  • 查找内容:
    (?:href=“/mp3files/cards/|\G)\K(?).mp3)(\S+(:\h+)(\.mp3))
  • 替换为:
    \L$1(?2$2:-)
  • 检查环绕
  • 检查正则表达式
  • 全部替换
说明:

(?:                     # non capture group
    href="/mp3files/cards/  # literally
  |                       # OR
    \G                      # restart fro last match position
)                       # end group
(?!\.mp3)               # negative lookahead, make sure we haven't ".mp3" after this position
\K                      # forget all we have seen until this position
(\S+)                   # group 1, 1 or more non spaces
(?:                     # non capture group
    \h+                     # 1 or more horizontal spaces
  |                       # OR
    (\.mp3)                 # group 2, literally ".mp3"
)                       # end group
\L$1            # lowercase content of group 1
(?2             # if group 2 exists (the extension .mp3)
    $2              # use it
  :               # else
    -               # put a hyphen
)               # endif
更换:

(?:                     # non capture group
    href="/mp3files/cards/  # literally
  |                       # OR
    \G                      # restart fro last match position
)                       # end group
(?!\.mp3)               # negative lookahead, make sure we haven't ".mp3" after this position
\K                      # forget all we have seen until this position
(\S+)                   # group 1, 1 or more non spaces
(?:                     # non capture group
    \h+                     # 1 or more horizontal spaces
  |                       # OR
    (\.mp3)                 # group 2, literally ".mp3"
)                       # end group
\L$1            # lowercase content of group 1
(?2             # if group 2 exists (the extension .mp3)
    $2              # use it
  :               # else
    -               # put a hyphen
)               # endif
屏幕截图(之前):

(?:                     # non capture group
    href="/mp3files/cards/  # literally
  |                       # OR
    \G                      # restart fro last match position
)                       # end group
(?!\.mp3)               # negative lookahead, make sure we haven't ".mp3" after this position
\K                      # forget all we have seen until this position
(\S+)                   # group 1, 1 or more non spaces
(?:                     # non capture group
    \h+                     # 1 or more horizontal spaces
  |                       # OR
    (\.mp3)                 # group 2, literally ".mp3"
)                       # end group
\L$1            # lowercase content of group 1
(?2             # if group 2 exists (the extension .mp3)
    $2              # use it
  :               # else
    -               # put a hyphen
)               # endif

屏幕截图(之后):

(?:                     # non capture group
    href="/mp3files/cards/  # literally
  |                       # OR
    \G                      # restart fro last match position
)                       # end group
(?!\.mp3)               # negative lookahead, make sure we haven't ".mp3" after this position
\K                      # forget all we have seen until this position
(\S+)                   # group 1, 1 or more non spaces
(?:                     # non capture group
    \h+                     # 1 or more horizontal spaces
  |                       # OR
    (\.mp3)                 # group 2, literally ".mp3"
)                       # end group
\L$1            # lowercase content of group 1
(?2             # if group 2 exists (the extension .mp3)
    $2              # use it
  :               # else
    -               # put a hyphen
)               # endif

哇,太简单了,非常感谢!再次感谢,托托(投票表决)。您能在替换中添加小写字母的更改吗?@Ken:有点复杂,请看我的编辑。托托,非常感谢。这对我来说真的很有帮助,也很有教育意义。