Skip to main content

How to get string between parenthesis?

  • December 9, 2017
  • 2 replies
  • 8 views

Abhi1540

Hi Experts,
I have a string between 2 parenthesis. how to get the string between 2 parenthesis as follows

my input is: (success)

output will be only success

how can i achieve this??

2 replies

marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • December 9, 2017

WITH input(s) AS (SELECT '(success)' )
SELECT REPLACE(REPLACE(s,'(',''),')','') FROM input;


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • December 10, 2017

You can also use the TRANSLATE function:

dbadmin=> select translate('(success)', '()', '') "What's inside the Parentheses?";
 What's inside the Parentheses?
--------------------------------
 success
(1 row)

See:
https://my.vertica.com/docs/9.0.x/HTML/index.htm#Authoring/SQLReferenceManual/Functions/String/TRANSLATE.htm