
Please explain to me why the following expression doesn’t output anything:
echo “” | egrep “”
but the following does:
echo “” | egrep “\”
The behaviour of the first is as expected but the second should not output. Is the “\
解决方案
AS @hwnd said \< matches the begining of the word. ie a word boundary \b must exists before the starting word character(character after \< in the input must be a word character),
In your example,
echo “” | egrep “”
In the above example, egrep checks for a literal < character present before the lastname string. But there isn't, so it prints nothing.
$ echo “” | egrep “\”
But in this example, a word boundary \b exists before lastname string so it prints the matched characters.
Some more examples:
$ echo “” | egrep “\
$ echo “” | egrep “\
$ echo “” | egrep “\
$ echo “” | egrep “\”
$ echo “” | egrep “\
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/229576.html原文链接:https://javaforall.net
