首页 > 编程知识 正文

java 正则表达式替换小括号的内容,java正则表达式移除中括号

时间:2023-05-06 12:33:37 阅读:276288 作者:73

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 "namelastname@domain.com" | egrep "

$ echo "namelastname@domain.com" | egrep "

$ echo "namelastname@domain.com" | egrep "

namelastname@domain.**com**

$ echo "" | egrep ""

$ echo "n-ame-lastname@domain.com" | egrep "

n-**ame-lastname@domain.com**

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。