I want to replace data after numbers with '' using regex_replace.
For example:
input --> output
MA0244891-D --> MA0244891
MA0244891 --> MA0244891
MA0244891D --> MA0244891
0244891D --> 0244891
I tried a few regex_replace as below:
REGEXP_REPLACE(rk.mystring, '[^0-9]+', '')) --> only get numbers
REGEXP_REPLACE(rk.mystring, '[^a-zA-Z0-9]+', '')) ---> get alphanumeric including the last characters
REGEXP_REPLACE(rk.mystring, '[^a-zA-Z][^0-9]+', '')) ---> almost correct but truncate numbers at the back
Appreciate your kind help
REGEXP_REPLACE(mystring, '(.*\\d).*', '$1')