Well here's one idea...
For ease of readability, in this solution I've substituted "\n" with "|".
And remember, just because you 'can', it doesn't follow that you 'should'!
SET @string = "the cat|sat on the|mat";
SELECT * FROM ints;
+---+
| i |
+---+
| 0 |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
+---+
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(@string,"|",i),"|",-1)x FROM ints;
+------------+
| x |
+------------+
| |
| the cat |
| sat on the |
| mat |
| mat |
| mat |
| mat |
| mat |
| mat |
| mat |
+------------+
SELECT LENGTH(SUBSTRING_INDEX(SUBSTRING_INDEX(@string,"|",i),"|",-1))x FROM ints ORDER BY x DESC LIMIT 1;
+------+
| x |
+------+
| 10 |
+------+