I have a string that contains some substrings seperated by a new line.
Forexample :
$x="This is the first line.
This is the second line.
This is the third line.";
I want to get the third line from this string,
My regex so far :
/\s*([^\n]+)/i
But this returns the whole string,
I have also tried
/\n{3}\s*([^\n]+)/i
It matched nothing.
Is there any way in regex to solve my problem? I have been trying to solve it myself for the last 30mnts, but all of my attempts failed.
preg_match_all("/\s*([^\n]+)/i",$x,$m);
print_r($m);
Thank you!
\nand get the last item? A regex is necessary when you have complex patterns. Here, you need to get some specific line.