Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如果行号和标记之间没有空格,我如何进行grep?_Regex_Sed_Grep - Fatal编程技术网

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>