I need the text delimited by "~ (Number from 0 to 13)" and ending at "~ end" each position of the array should have the text that is between the braces. Does anybody have an idea ?
TEXT: (The original has a lake text and maybe html)
~0
aaaaaa1
aaaaaaaaaa
~1
bbbbbbbbbb
sdf23
324 <br>
sdfs
~2
cccccccccc
~3
ddddddddddd
~13
eeeeeeeeeee
~14
fffffffffff
~end
END Array:
Array
(
[0] => aaaaaa1
aaaaaaaaaa
[1] => bbbbbbbbbbb
sdf23
324 <br>
sdfs
[2] => cccccccccc
[3] => dddddddddd
.
.
.
.
[13] => eeeeeee
[14] => fffffff
)
My PHP with regex: (fail)
$texto = "
~0
123hola321
yyyyyyyyyyy
~1
rrrrrrrrrrrr
sdf23
324 <br>
sdfs
~2
cccccccccc
~3
ddddddddddd
~13
ddddddddddd
~14
ddddddddddd
~end ";
$regex = '/^~(\d{1,2}.\n)(.*?)/m';
echo $regex;
preg_replace($regex,$texto,$matches);
echo "<pre>";
print_r($matches);
echo "</pre>";
// ^~(\d{1,2}.\n)
// ~\d{1,2} (.*?)2$
//
// ^~\d{1,2}(.*?)end$
thx