0

I have these strings:

[{"Name":"id","Value":"Window_Ex_kebklipecbcegiocpa_widget_open"
[{"Name":"id","Value":"Window_Ex_kebklipecbcegiocpa_widget_close"
[{"Name":"id","Value":"Window_Ex_kebklipecbcegiocpa_widget_mid_value"

and I'm trying to extract only the parts after the third _, until the end of the string (which ends always with ")

widget_open
widget_close
widget_mid_value

I'm using postgresql, and wanted to use the regexp_substr syntax, in order to extract it. Thanks!

1
  • Show us what you tried and why that didn't work. Commented Jan 4, 2021 at 16:26

1 Answer 1

1

regexp_replace(data::text,'^([^_]+_){3}','')

You can try

select regexp_replace(data::text,'^([^_]+_){3}','')
  from (
      select 'one_two_three_four  s'::text as data 
      union select 'a_bb_ccc_dddd_eeee_ffff'
  ) data

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.