Regex 正则表达式替换方括号之间的字符,但不替换括号之间的字符
我有一个降价链接列表,如下所示:Regex 正则表达式替换方括号之间的字符,但不替换括号之间的字符,regex,sublimetext3,regex-lookarounds,Regex,Sublimetext3,Regex Lookarounds,我有一个降价链接列表,如下所示: [filename-with-some-words](/001-folder/filename-with-some-words.md) [title-with-other-words](/001-folder/title-with-other-words.md) [other-words](/001-folder/other-words.md) 我想替换方括号中出现的-,[],而不是括号中出现的(),这样我的最终结果如下所示: [filename with s
[filename-with-some-words](/001-folder/filename-with-some-words.md)
[title-with-other-words](/001-folder/title-with-other-words.md)
[other-words](/001-folder/other-words.md)
我想替换方括号中出现的-
,[]
,而不是括号中出现的()
,这样我的最终结果如下所示:
[filename with some words](/001-folder/filename-with-some-words.md)
[title with other words](/001-folder/title-with-other-words.md)
[other words](/001-folder/other-words.md)
我可以用(?您可以使用
(?:\G(?!\A)|\[)[^][-]*\K-(?=[^][]*])
替换为空格。请参见
详细信息
(?:\G(?!\A)\[)
-上一次成功匹配的结束或[
[^][-]*
-除]
、[
和-
以外的任何0+字符
\K
-匹配重置操作符丢弃所有匹配的文本,直到整个匹配内存缓冲区
-
-连字符
(?=[^][]*])
-后面跟0+个无括号字符,直到]
字符