1

I want to get values between = and ^ . My expression like;

select regexp_substr('NUMBER=2019-024^','\={1}([^^]+)',1, 1) from dual

I want only 2019-024 part. With these expression I got "=2019-024". How can I get 2019-024?

Thank you!

2
  • You can shorten it to =([^^]+) and take the group 1 value Commented Feb 4, 2021 at 8:09
  • It doesnt work. Still getting =2019-024 Commented Feb 4, 2021 at 8:12

2 Answers 2

2

I might even suggest not using regex here and instead resort to the base string functions:

SELECT SUBSTR(col, INSTR(col, '=') + 1, INSTR(col, '^') - INSTR(col, '=') - 1)
FROM yourTable;

If you really want to use regex here, then use a capture group:

SELECT REGEXP_SUBSTR('NUMBER=2019-024^', '=(.*?)\^', 1, 1, NULL, 1) FROM dual;
Sign up to request clarification or add additional context in comments.

Comments

0

You don't have to escape the \= and you an omit {1}.

Add matching a \^ (which does have to be escaped) at the end to make sure that it is there.

The syntax for the capture group is:

SELECT REGEXP_SUBSTR('NUMBER=2019-024^', '=([^^]+)\^', 1, 1, NULL, 1) FROM dual;

Output

2019-024

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.