我以为这两个调用sed
将返回相同的输出,因为默认情况下它以贪婪的方式查找模式。为什么不?
$ echo '<a href="/topic/null-hypothesis/" data-sc="text link:topic link">Null hypothesis</a>' | grep -E '<a href="/topic.*</a>' | sed 's/<a href=.*">//'
Null hypothesis</a>
$ echo '<a href="/topic/null-hypothesis/" data-sc="text link:topic link">Null hypothesis</a>' | grep -E '<a href="/topic.*</a>' | sed 's/<a href=.*>//'
PS:
$ bash --version
bash --version
GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)
PS2:我从改正sed
为grep
。
PS3:从改正grep
为sed
。
我在这里没有看到任何违规行为。">
与匹配link">
,但不</a>
与匹配,由匹配>
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句