这个问题在这里已经有了答案:
Circumvent the sed backreference limit \1 through \9
(5 个回答)
6年前关闭。
通常当你调用 sed 时,你可以调用 \1
引用第一个子匹配,即:
<something> | sed "s/<regex>\(<regex>\)<regex>/\1/"
这将只采用中间的正则表达式并删除外部的正则表达式。
但是,如果您有超过 9 场比赛,您会怎么做?简单写
\10
不起作用,因为它将被解释为 take submatch number one and add a zero behind it
.
最佳答案
这在 sed 中是不可能的。您将不得不使用不同的工具。
以下是关于 SO 的类似问题:
Circumvent the sed backreference limit \1 through \9 .
how to get 10th grouping value in sed?
关于regex - 引用第 10 次子赛,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11833104/