February 5th, 2013, 05:24 PM
Near trivial optional group
I'm having a brain freeze or something. I can't figure out how to do a trivial group.
grep "<us-references-cited>" ipg130122.xml
results in lots of lines, like:
grep "<(us-)references-cited>" ipg130122.xml
can't find any. Clearly this an operator error. Thanks
February 5th, 2013, 06:54 PM
In regular non-GNU grep, ( ) are actually literal characters and \( \) will group.
February 5th, 2013, 06:57 PM
Ah, ok, now do you know how python interprets the parens? Does it want them quoted, or unquoted?
February 5th, 2013, 07:53 PM
That \( is pretty unusual - it's normally the complete opposite behavior.
The re docs say that ( ) is the correct form: no backslashes.