Vaishali Shinde
Vaishali Shinde

Reputation: 552

I want regular expression remove brackets in PostgreSQL version 9.3.5

I want regular expression that's remove to brackets in PostgreSQL version 9.3.5

example

3136.27(0.31A.G)

output is 3136.27

and i am using for following regular expression but it's not working postgesql version 9.3.5

SELECT regexp_replace('3136.27(0.31A.G)', '/(([^)]+))(\s*-)/', '$1$2')

Upvotes: 2

Views: 98

Answers (2)

Laurenz Albe
Laurenz Albe

Reputation: 246698

SELECT regexp_replace('3136.27(0.31A.G)', '\(.*\)', '');

┌────────────────┐
│ regexp_replace │
├────────────────┤
│ 3136.27        │
└────────────────┘
(1 row)

Upvotes: 2

krasipenkov
krasipenkov

Reputation: 2029

I think this will work for you if you want your output to be 3136.27:

SELECT regexp_replace('3136.27(0.31A.G)', '/(([^()]+))(\(.*\))/', '$1')

Upvotes: 0

Related Questions