0

My input value is something like:

Value:123 with subvalues:[134,135,136]

I just want to pull all of the numbers from this and keep them comma-delimited if they are seperated by at least one non-digit character. I'm using this right now:

regexp_replace(message,  '[^[:digit:]]')

This pulls the numbers, but obviously replacing even the spaces between those numbers with nothing. How can I get the result of:

123,134,135,136
1
  • 1
    Honestly, it sounds like what you are doing should be addressed in the application logic, not in the database. Commented Jun 25, 2013 at 20:07

1 Answer 1

2
select
    regexp_replace(
        regexp_replace(
            'Value:123 with subvalues:[134,135,136]',
            '[^[:digit:]]+', ','),
        '^,+|,+$'
    ) as s
from dual;

Result:

s
---------------
123,134,135,136
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.