Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to extract from string between the last 2 "symbol use REGEXP_SUBSTR in sql

the string is like this

a:3:{s:8:"ref_type";s:4:"user";s:3:"tid";s:18:"TXID17073204182661";s:7:"message";s:19:"3757000431691375718";}

I want to get only the text between the last 2 ", which is 3757000431691375718

I have tried REGEXP_SUBSTR(wml.data, '[^:]+$') but this will return "3757000431691375718";}
Anyone can help?
Thank you

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You might use this pattern :

SELECT *, REGEXP_SUBSTR(data, '(?<=\")[^"]+(?="[^"]*$)')
FROM mytable

The pattern matches:

(?<=\") Assert a " to the left
[^"]+ Match 1+ occurrences of any char except "
(?="[^"]*$) Assert a " to the right, followed by any char except "

Demo here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading