Thej Kumar Thej Kumar - 6 months ago 8
SQL Question

SQL to find last alpha value in a string

I need to find last alhpa value in a string .

My string will be like below :

thj_ujk_008j_1
tky_ujk_098f_*/_2


My result should be :

j
f

Answer

You can try using regexp_replace() and select out the matched final alpha value which you are seeking:

select regexp_replace(col, '.*([a-zA-Z]).*', '\1')
from yourTable

This regex appears to be working properly when tested using Regex101:

Regex101