-2

I can usually get by with Regex but this one's doing my head in and I will gratefully accept anyone's help.

select regexp_replace(upper('Abc\Zyxcz\'),'[^A-Z]+', '');

This returns ABCZYXCZ\ although I'd expect it to remove all the backslashes.

Anything I am missing? Thank you!

Gayathri
  • 274
  • 3
  • 17

1 Answers1

1

Your replacement will only perform one replacement. Add the [g]lobal flag as an extra argument:

select regexp_replace(upper('Abc\Zyxcz\'),'[^A-Z]+', '', 'g');
trincot
  • 317,000
  • 35
  • 244
  • 286