#1
  1. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Sep 2007
    Location
    outside Washington DC
    Posts
    2,642
    Rep Power
    3699

    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:

    <us-references-cited>
    <us-references-cited>

    but
    grep "<(us-)references-cited>" ipg130122.xml

    can't find any. Clearly this an operator error. Thanks
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    In regular non-GNU grep, ( ) are actually literal characters and \( \) will group.
  4. #3
  5. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Sep 2007
    Location
    outside Washington DC
    Posts
    2,642
    Rep Power
    3699
    Ah, ok, now do you know how python interprets the parens? Does it want them quoted, or unquoted?
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    That \( is pretty unusual - it's normally the complete opposite behavior.

    The re docs say that ( ) is the correct form: no backslashes.

IMN logo majestic logo threadwatch logo seochat tools logo