Last word in a sentence: In SQL (regular expressions possible?) Last word in a sentence: In SQL (regular expressions possible?) oracle oracle

Last word in a sentence: In SQL (regular expressions possible?)


I reckon it's simpler with INSTR/SUBSTR:

WITH q AS (SELECT 'abc def ghi' AS sentence FROM DUAL)SELECT SUBSTR(sentence, INSTR(sentence,' ',-1) + 1)FROM q;


Not sure how it is performance wise, but this should do it:

select regexp_substr(&p_word_in, '\S+$') from dual;


I'm not sure if you can use a regex in oracle, but wouldn't

(\w+)\W*$

work?