更新时间:2023-02-18 20:20:40
按如下所示修改您的sed
命令应提取您想要的内容,
Modify your sed
command as followed should extract what you want,
sed -e "$(sed 's:\<.*\>:s/&\\w*\\s//ig:' file.txt)"
简要说明,
\b
匹配单词和非字母数字字符之间的位置.在这种情况下,file.txt中的模式"test"将与"Testing"不匹配. \w*
的搜索模式应该可以. \w
实际上与[a-zA-Z0-9_]
\s
.\b
matches the position between a word and a non-alphanumeric character. In this case, the pattern 'test' in file.txt would not match 'Testing'. \w*
should work. \w
actually matched [a-zA-Z0-9_]
\s
should be added.