Search code examples
mysqltrim

Clear both the left 14 characters and "x" right, after a specific character


i have a mysql table with records like:

<font size=1>ANGRY BIRDS 2<br>Thurop Van Orman, John Rice (USA, Finland)<br>5/9/2019 – Spentzos Film</font>
<font size=1>THE FAVORITE<br>Giorgos Lanthimos (USA, UK, Irland)<br>5/9/2019 - Feelgood Ent</font>

What I need is to keep only the Title of the movie clearing all the unwanted left and right characters

ANGRY BIRDS 2
THE FAVORITE

I tried

 SUBSTR(`Title`, 14)

and

SUBSTRING_INDEX(`Title`, '<br>', 1)

I also tried to combine Leading and Trailing in one line like

TRIM(Leading '<font size=1>' FROM `tbl.`Title`),
                trim(trailing from `tbl`.`Title`, '<br>', 1)

but it doen't work Is that possible to get the result I need?


Solution

  • SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`Title`, '<', 2), '>', -1)