根据https://regex101.com/r/KVQPk0/1,下面的regex (在我的实际用例中,我需要组作为后面的引用):
<latex>\$([^$]*)\$<\/latex>(full)与字符串<latex>$\rightarrow$</latex>匹配,但sed似乎不理解这一点。的确:
echo "<latex>$\\\rightarrow$</latex>" | sed -E -e "#<latex>\$([^$]*)\$</latex>#\:math\:\&$1@#d"(应该返回空字符串)逐字返回:
<latex>$\rightarrow$</latex>从<latex>$\rightarrow$</latex>的角度来看,与sed匹配的正则表达式是什么?
编辑
我混淆了我的测试和应该不返回的命令(AFAIU)是:
echo "<latex>$\\\rightarrow$</latex>" | sed -E -e "#<latex>\$([^$]*)\$</latex>#d"编辑2
我的外壳是zsh。
发布于 2022-09-13 12:36:34
感谢这些评论,下面是从<latex>$\rightarrow$</latex>的角度来看与sed匹配的正则表达式:
printf '%s\n' '<latex>$\rightarrow$</latex>' | sed -E -e '/<latex>\$([^$]*)\$<\/latex>/d'https://stackoverflow.com/questions/73694034
复制相似问题