I have 2 regex below which works in php 5.6 but will not work in php 7.x if the character + white space > 1035 ish. Ex: [spoiler]1035 count of char + ws[/spoiler] . I used site, http://regexr.com/, to test the regex with http://pastebin.com/5bWzhNvy and it seems to work fine.
From PHP 7 regex not working the same way as in 5, i can see that issue could be with regex timing out? But here's the code unless I am mistaken.
// [spoiler]Text[/spoiler]
preg_match_all('/\[spoiler\]\s*((\s|.)+?)\s*\[\/spoiler\]/', $s, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$id = substr(md5($match[1]), 0, 10) . mt_rand(0, 10000);
$s = str_replace($match[0],
'<a href="javascript:klappe_function(\'' . $id . '\')" style="color: #aaa" title="Open Spoiler"><img src="images/plus.png" id="pic' . $id . '" class="spoiler" alt="spoiler" /></a><div id="k' . $id . '" style="display: none;">' . $match[1] . '</div><br />',
$s);
}
// [spoiler=Heading]Text[/spoiler]
preg_match_all('/\[spoiler=(.+?)\]\s*((\s|.)+?)\s*\[\/spoiler\]/', $s, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$id = substr(md5($match[2]), 0, 10). mt_rand(0, 10000);
$s = str_replace($match[0],
'<a href="javascript:klappe_function(\'' . $id . '\')" style="color: #aaa" title="Open ' . myhtmlentities($match[1], ENT_QUOTES) . '"><img src="images/plus.png" id="pic' . $id . '" class="spoiler" alt="spoiler" /> <b>' . $match[1] . '</b></a><div id="k' . $id . '" style="display: none;">' . $match[2] . '</div><br />',
$s);
}