sqldatabasereplaceregexp-replacegreenplum

SQL REGEXP_REPLACE() function


I have a table with names that has the values like this:

Customer
marco rossi
.paolo esposito
jimmi montana
**Luke skywalker
marinella abc
- ÚDRST MARK
-úgo srl

What i wanted was to delete all the special characters in the beginning of the names. I used this function REGEXP.REPLACE('[^a-zA-Z0-9]|[^a-zA-Z0-9]$/g',''))

And this return me almost what i wanted but delete me also the Ú, ú So instead of having [ ÚDRST MARK ] i have [ DRST MARK ]

What i can add in this function for not replacing the characters with accents in the beginning of the words?

Thank u so much guys.


Solution

  • If you want to keep the Ú and ú special characters, what about adding them inside the non capturing group?

    REGEXP.REPLACE('[^a-zA-Z0-9Úú]|[^a-zA-Z0-9Úú]$/g',''))
    

    Does it work for you?