How replace last character of string with blank if last character is dots.
Example:
Select replace('Luis Nazario Ronaldo Da Lima.',' ','.') as Name from dual
union all
Select replace('Ronaldo de Assis Moreira',' ','.') as Name from dual
From first name need remove dots at the end of string, second name is ok.
I need this resault:
LuisNazarioRonaldoDaLima
RonaldodeAssisMoreira
You could use REGEXP_REPLACE
:
SELECT REGEXP_REPLACE('Luis Nazario Ronaldo Da Lima.', ' |\.$', '') AS Name FROM dual
UNION ALL
SELECT REGEXP_REPLACE('Ronaldo de Assis Moreira', ' |\.$', '') FROM dual;
This outputs:
LuisNazarioRonaldoDaLima
RonaldodeAssisMoreira
The regex pattern used here is \.$
, and will target either spaces or the final character of the string if that final character be dot.