具有正则表达式的grep的范围 [英] Scope of grep with regular expressions

查看:91
本文介绍了具有正则表达式的grep的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Linux的grep命令中使用正则表达式

 (^ \ s * \ * \\ \\ * \ [\] [^ \ *] +?(\ w * \:[^ \ *] + \ d $)|([^ \ *] + [。] com [。] au $))

当我在 https://www.regextester.com 与一个文件的内容,我得到所需的结果,即所需的字段得到匹配但是当我试图使用它作为

  grep'(^ \ s * \ * \s \\ \\ \\ [\] [^ \ *] +?(\ w * \:[^ \ *] + \ d $)|([^ \ *] + [。] com [。] au $ ))'file1 

它给了我一个空!



这里有什么问题?

解决方案

  pcregrep -M'( ^ \s * \ * \s * \ [\] [^ \ *] +?(\ w * \:[^ \ *] + \ d $)|([^ \ *] + [。] com [。] au $))'

这样做:)

I am trying to use a regular expression with grep command of Linux

(^\s*\*\s*\[ \][^\*]+?(\w*\:[^\*]+\d$)|([^\*]+[.]com[.]au$))

When I am trying it out at https://www.regextester.com with the contents of a file, I am getting the required result, i.e., the required fields are getting matched but when I am trying to use it as

grep '(^\s*\*\s*\[ \][^\*]+?(\w*\:[^\*]+\d$)|([^\*]+[.]com[.]au$))' file1

all it gives me is a null!

What's the problem here?

解决方案

pcregrep -M  '(^\s*\*\s*\[ \][^\*]+?(\w*\:[^\*]+\d$)|([^\*]+[.]com[.]au$))'

did the trick :)

这篇关于具有正则表达式的grep的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆