标签: regex bash sed
为什么echo 'word word word word word word' | sed 's/[a-zA-Z]* /DELETED /2g'
echo 'word word word word word word' | sed 's/[a-zA-Z]* /DELETED /2g'
打印word DELETED DELETED DELETED DELETED word?
word DELETED DELETED DELETED DELETED word
为什么 sed 没有替换上一个word?
word
答案 0 :(得分:4)
因为正则表达式有一个尾随空格:
/[a-zA-Z]* / ^
它明确地搜索零个或多个字母后跟一个空格。