Search code examples
sqloracleoracle-sqldeveloper

How to remove digits and special characters from the beginning of a string?


For instance I have

'234 - ? Hi there'

The result should be:

'Hi there'

Solution

  • For oracle you have the regexp_replace function. So you could do the below to replace non-alphabetic characters from the beginning of the string:

    select regexp_replace('24 Hi','^([^a-zA-Z]*)','') from dual
    

    The first ^ in ^([^a-zA-Z]*) is to match the beginning of the string. The second ^ is to match any non-alphabetic characters.