I was replacing blank lines for a <p>
tag.
The regex replace all blacklines allowing white-spaces (\s), for one <p>
tag.
For example this string:
$string="with.\n\n\n\nTherefore";
But return 2 <p>
tags.
So, i've done this test:(It's not for replace
, just for test)
$string="with.\n\n\n\nTherefore";
$string=preg_replace('/(^)(\s*)($)/m','[$1]|$2|($3)',$string);
echo $string;
And check what's return:
with.
[]|
|()[]||()
Therefore
Imagining:
with.\n
^\n
\n
$^\n$\n
Therefore
The regex add one \n, and the 4th one does not do what 'she' have to do.(jump to the another line).
Someone that can help. basically explain rather than solve the problem. Thanks evryone.