Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

grep -E ungreedy

I can't seem to get ungreedy (?) to work in grep.


echo "This is a <EM>first</EM> test" | grep -E -o '<.+?>'

returns <EM>first</EM> (not <EM> </EM>)


(I can use '<[^>]+>', but why isn't '<.+?>' working?)


Tony

MacBook Air, MacBook, Mac mini-OTHER, Mac OS X (10.7.3)

Posted on Apr 30, 2012 5:18 AM

Reply
Question marked as Best reply

Posted on Apr 30, 2012 5:54 AM

I do not see in "man grep" (nor "man re_format") where it talks about supporting .+? syntax. Are you confusing a different platform's grep or perhaps perl's regular expressions?

2 replies

grep -E ungreedy

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.