Skip navigation

grep -E ungreedy

343 Views 2 Replies Latest reply: Apr 30, 2012 7:10 AM by Tony T1 RSS
Tony T1 Level 6 Level 6 (8,125 points)
Currently Being Moderated
Apr 30, 2012 5:28 AM

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, Mac OS X (10.7.3)
  • BobHarris Level 6 Level 6 (12,505 points)
    Currently Being Moderated
    Apr 30, 2012 5:54 AM (in response to Tony T1)

    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?

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.