[sed] how to ONLY get the stuff between \(.*\)??? - Unix

This is a discussion on [sed] how to ONLY get the stuff between \(.*\)??? - Unix ; Hi people! I'm just at trying to get only the stuff between the \(\) in sed... here's an example: echo "\$aadr .= ((Fields::exists('atelland') OR Fields::exists('atelvor') OR Fields::exists('atelnr'))?\" " | sed - n -e "s/Fields::exists[ ]*([']*\([^')]*\)[']*)/\1/igp" That line above returns this: ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [sed] how to ONLY get the stuff between \(.*\)???

  1. [sed] how to ONLY get the stuff between \(.*\)???

    Hi people!

    I'm just at trying to get only the stuff between the \(\) in sed...
    here's an example:

    echo "\$aadr .= ((Fields::exists('atelland') OR
    Fields::exists('atelvor') OR Fields::exists('atelnr'))?\"" | sed -
    n -e "s/Fields::exists[ ]*([']*\([^')]*\)[']*)/\1/igp"

    That line above returns this:

    .= ((atelland OR atelvor OR atelnr)?"

    But I want it to return this:

    atelland atelvor atelnr

    OR if it is even possible, it would be great if it could return:

    atelland
    atelvor
    atelnr

    Any idea? Thanks!

  2. Re: how to ONLY get the stuff between \(.*\)???

    On Sep 17, 3:41 am, Criz Collins wrote:
    > Hi people!
    >
    > I'm just at trying to get only the stuff between the \(\) in sed...
    > here's an example:
    >
    > echo "\$aadr .= ((Fields::exists('atelland') OR
    > Fields::exists('atelvor') OR Fields::exists('atelnr'))?\"" | sed -
    > n -e "s/Fields::exists[ ]*([']*\([^')]*\)[']*)/\1/igp"
    >
    > That line above returns this:
    >
    > .= ((atelland OR atelvor OR atelnr)?"
    >
    > But I want it to return this:
    >
    > atelland atelvor atelnr
    >
    > OR if it is even possible, it would be great if it could return:
    >
    > atelland
    > atelvor
    > atelnr
    >
    > Any idea? Thanks!


    This might be easier in Perl, where you can use a construct like:
    perl -n -e 'while(m/(...)/g){ print "$1 " }'

+ Reply to Thread