무효 반복 연산자 피연산자는 나는이 정규 표현 (?<=heads\/)(.*?)(?=\n)
을 가지고 있고 http://regexr.com?347dm그렙 :
내가 grep 명령에서 작동이 정규식이 필요 여기서 일하는하지만이 오류가있어 그것을 볼 수 있습니다.
$ grep -Eio '(?<=heads\/)(.*?)(?=\n)' text.txt
grep: repetition-operator operand invalid
그것은 ack에서 훌륭하게 작동하지만, 나는 이것을 실행할 필요가있는 기계를 가지고 있지 않습니다.
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 및 ack는 약간 다른 정규 표현식 구문을 사용하는 것처럼 보입니다. grep이 좋아하지 않는 것을 찾을 때까지 regex에서 반복 문자를 삭제하십시오. –
내 실수. 나는 그것이 옳았다 고 편집했다. 같은 문제. – jspooner
내 의견을 오해했습니다. 나는 grep 정규 표현식 언어와 ack regex 언어가 동일하지 않다는 것을 말하고있다. 차이점을 찾기 위해 문제를 스스로 디버깅 할 수 있도록 노력하고 있습니다. ([여기에 답이있다.] (http://www.regular-expressions.info/posix.html). –