On Mon, Mar 07, 2011, Robert Grasso wrote:
Hello,
On my opinion, grep is not powerful enough in order to achieve what you want. It would be preferable to use at least some (old but powerful) tools such sed, awk, or even better : perl. Actually, what you need is a tool providing a capture buffer (this is perl jargon - "back references" in sed jargon) in which you can get the string you want to extract, rather than trying to build up a positive matching regex, as the string boundaries seem to be easy enough to describe with regexs.
One can use pcregrep which is grep that groks perl regular expressions.
Bill