Regex 如果行号和标记之间没有空格,我如何进行grep?
这将是:Regex 如果行号和标记之间没有空格,我如何进行grep?,regex,sed,grep,Regex,Sed,Grep,这将是: grep -in "todo" test.html | sed -e "s/^[1-9]\d*:[ \t]*//" todo:测试 但我想要这个: <span>todo:test<span> 1:todo:test 您可以使用此sed: 1:<span>todo:test<span> 测试: sed '/todo/s/^\([1-9]\+:\)[ \t]*/\1/' file.html $echo“1:todo:test”|
grep -in "todo" test.html | sed -e "s/^[1-9]\d*:[ \t]*//"
todo:测试
但我想要这个:
<span>todo:test<span>
1:todo:test
您可以使用此sed
:
1:<span>todo:test<span>
测试:
sed '/todo/s/^\([1-9]\+:\)[ \t]*/\1/' file.html
$echo“1:todo:test”| sed'/todo/s/^\([1-9]\+:\)[\t]*/\1/'
1:待办事项:测试
sed '/todo/s/^\([1-9]\+:\)[ \t]*/\1/' file.html
$ echo "1: <span>todo:test<span>" | sed '/todo/s/^\([1-9]\+:\)[ \t]*/\1/'
1:<span>todo:test<span>