3

What's the Diff Between These Two Regexes?

view full story
linux-howto

http://www.unix.com – Trying to understand what's happening here, but I cannot figure it out. I'm reading Mastering Regular Expressions, by Friedl, and he uses this as an example of how to grab quoted text: Code: egrep -o '"[^"]*"' ~/File.txt ...should pull in any quoted phrases. Match a literal double-quote, match anything not a double-quote until you hit the next literal double-quote. But, he says [^"]* can match a newline, thereby returning quoted text even if it crosses lines. If you want to keep it from crossing lines, you should use this: Code: egrep -o '"[^"\n]*& (HowTos)