user7148991
user7148991

Reputation:

Replacing with sed a string containing parenthesis with a substring of contained date into the parenthesis

I want to replace with "sed" a string containing parenthesis with a part of the contained string into the parenthesis.

Input

to_date('04/10/12','DD/MM/RR')

Output

'04/10/12'

Is it possible? How?

Multiple occurrences can exist in the input

I tried

sed -e 's/to_date(//'' -e 's/,\'DD/MM/RR\')//g'

but I would like a one substitute expression

Upvotes: 1

Views: 658

Answers (2)

ctac_
ctac_

Reputation: 2471

You can use this sed too

sed -E "s/[^']*('[^']*').*/\1/" <<< "to_date('04/10/12','DD/MM/RR')"

Upvotes: 0

anubhava
anubhava

Reputation: 785098

You can use this sed:

sed -E "s/to_date\(('[^']+')[^)]*\)/\1/g" <<< "to_date('04/10/12','DD/MM/RR')"

'04/10/12'

Upvotes: 2

Related Questions