0

I have a ["1101124","1101123","123456"], I need to get the end result as rows for the numbers which are in the bracket. How can I achieve this by using regular expression in Oracle.

0

2 Answers 2

1

Don't use regular expression to try to parse JSON data; use a proper JSON parser:

SELECT value
FROM   JSON_TABLE(
         '["1101124","1101123","123456"]',
         '$[*]'
         COLUMNS(
           value VARCHAR2(20) PATH '$'
         )
       )

Outputs:

VALUE
1101124
1101123
123456

db<>fiddle here

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

Comments

0

If ["1101124","1101123","123456"] is a string:

SQL> WITH DATA AS
  2    ( SELECT '["1101124","1101123","123456"]' str FROM dual
  3    )
  4  SELECT trim(regexp_substr(str, '[0-9]+', 1, LEVEL)) str
  5  FROM DATA
  6  CONNECT BY regexp_substr(str , '[0-9]+', 1, LEVEL) IS NOT NULL
  7  /

STR
----------------------------------------
1101124
1101123
123456

3 rows selected.

SQL>

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.