Let’s say I have a string of random characters, and I want to extract only the string that starts after a specific keyword (including the keyword). How could I do so using MySQL or MariaDB? …………..
String example:
axdsSSFddlwie ====> SSFddlwie
aldfklafnlanaSSFiiie ====> SSFiiie
iiiSSFnnnn ====> SSFnnnn
Thanks for the help!
Advertisement
Answer
Using the base string functions we can try:
SELECT SUBSTRING(col, INSTR('SSF', col)) FROM yourTable;
If you are using MySQL 8+, then REGEXP_SUBSTR
is another option:
SELECT REGEXP_SUBSTR(col, 'SSF.*') FROM yourTable;