grep:重复操作符操作数无效 [英] grep: repetition-operator operand invalid
本文介绍了grep:重复操作符操作数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个正则表达式(?<= heads \ /)(.*?)(?=\\\
,你可以看到它在这里工作
)
http://regexr.com?347dm
$ grep -Eio'这个正则表达式在grep命令中工作,但我得到这个错误。 (?<= heads \ /)(.*?)(?=\\\
)'text.txt
grep:重复操作符操作数无效
它在ack中工作的很好,但我没有对我需要运行的机器进行验证。
ack text.txt -o --match'(?<= heads \ / )(.*?)(?=\\\
)'
text.txt
74f3649af36984e1b784e46502fe318e91d29570 HEAD
06d4463ab47a6246e6bd94dc3b9267d59fc16c2e refs / heads / ARC
0597e13c22b6397a1b260951f9d064f668b26f08 refs / heads / LocationAge
e7e1ed942d15efb387c878b9d0335b37560c8807 refs / heads / feature / 311-312-breaking-banner-updates
d0b2 632b465702d840a358d0b192198ae505011c裁判/头/海湾新闻
509173eafc6792739787787de0d23b0c804d4593裁判/头/ JBB-新的applicationDidFinishLaunching
1e7b03ce75b1a7ba47ff4fb5128bc0bf43a7393b裁判/头/ locationdebug
74f3649af36984e1b784e46502fe318e91d29570裁判/头/主
5d2ede384325877c24db7ba1ba0338dc7b7f84fb裁判/头/混合媒体
3f3b6a81dd3baea8744aec6b95c2fe4aaeb20ea3裁判/头/-onezero后
4198a43aab2dfe72d7ae9e9e53fbb401fc9dac1f裁判/头/白色标签
76741013b3b2200de29f53800d51dfd6dc7bac5e裁判/标签/ R10
fc53b1a05dad3072614fb397a228819a67615b82裁判/标签/ R10 ^ {}
afdcfd970c9387f6fda0390ef781c2776aa666c3 refs / tags / r11
解决方案
grep does不支持(?< = ...)
或 *?
或(? = ...)
运算符。请参阅此表格。
I have this regular express (?<=heads\/)(.*?)(?=\n)
and you can see it working here
http://regexr.com?347dm
I need this regex to work in the grep command but I'm getting this error.
$ grep -Eio '(?<=heads\/)(.*?)(?=\n)' text.txt
grep: repetition-operator operand invalid
It works great in ack but I dont have ack on the machine I need to run this on.
ack text.txt -o --match '(?<=heads\/)(.*?)(?=\n)'
text.txt
74f3649af36984e1b784e46502fe318e91d29570 HEAD
06d4463ab47a6246e6bd94dc3b9267d59fc16c2e refs/heads/ARC
0597e13c22b6397a1b260951f9d064f668b26f08 refs/heads/LocationAge
e7e1ed942d15efb387c878b9d0335b37560c8807 refs/heads/feature/311-312-breaking-banner-updates
d0b2632b465702d840a358d0b192198ae505011c refs/heads/gulf-news
509173eafc6792739787787de0d23b0c804d4593 refs/heads/jbb-new-applicationdidfinishlaunching
1e7b03ce75b1a7ba47ff4fb5128bc0bf43a7393b refs/heads/locationdebug
74f3649af36984e1b784e46502fe318e91d29570 refs/heads/master
5d2ede384325877c24db7ba1ba0338dc7b7f84fb refs/heads/mixed-media
3f3b6a81dd3baea8744aec6b95c2fe4aaeb20ea3 refs/heads/post-onezero
4198a43aab2dfe72d7ae9e9e53fbb401fc9dac1f refs/heads/whitelabel
76741013b3b2200de29f53800d51dfd6dc7bac5e refs/tags/r10
fc53b1a05dad3072614fb397a228819a67615b82 refs/tags/r10^{}
afdcfd970c9387f6fda0390ef781c2776aa666c3 refs/tags/r11
解决方案
grep does not support the (?<=...)
or *?
or (?=...)
operators. See this table.
这篇关于grep:重复操作符操作数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文