0

Why would this one work:

SELECT REGEXP_REPLACE(REGEXP_REPLACE('[GREY]', '\]', ''), '\[', '')

But these not:

SELECT REGEXP_REPLACE('[GREY]', '[\[\]]', '')
SELECT REGEXP_REPLACE('[GREY]', '/[\[\]]/g', '')

This is the explanation from regex101.com:

/[\[\]]/g

Match a single character present in the list below [\[\]]
    \[ matches the character [ literally (case sensitive)
    \] matches the character ] literally (case sensitive)

Global pattern flags
    g modifier: global. All matches (don't return after first match)

And Match Information:

Match 1
    Full match  0-1 `[`
Match 2
    Full match  5-6 `]`

1 Answer 1

3

REGEXP_REPLACE takes flags e.g. g as a separate parameter:

SELECT REGEXP_REPLACE('[GREY]', '[\[\]]', '', 'g') returns GREY

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.