N
N
Nikolay Baranenko2017-09-07 13:41:59
Oracle
Nikolay Baranenko, 2017-09-07 13:41:59

What is the best way to optimize a regular expression?

Hello.
Today I had to solve a problem with a regular expression in PL-SQL
, for example, from
select 'SESSION_WAIT' as name, (select UM.MON_SESSION_WAIT from dual) as value from DUAL , I decided to
pull out SESSION_WAIT
in this way

SELECT 
SUBSTR(REGEXP_SUBSTR('select ''SESSION_WAIT'' as name, (select UM.MON_SESSION_WAIT from dual) as value from DUAL', '''[^'']+'''),2,LENGTH(REGEXP_SUBSTR('select ''SESSION_WAIT'' as name, (select UM.MON_SESSION_WAIT from dual) as value from DUAL', '''[^'']+'''))-2)
FROM DUAL

but I feel there is a better option...
What is the best way to optimize this solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vovik0134, 2017-09-14
@vovik0134

Specifically, in your case, you can use the following expression:
\1 selects the first group from the regular expression
More about regexp_replace

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question