We have HTML (created by WYSIWYG editors) that contain <strong> tags with <br /> tags inside. Because the <br /> tags are converted to new lines before <strong> is being converted to uppercase, and the regexp doesn't match new lines, it prevents the <strong> from being converted to uppercase.
Example:
<strong>This would<br />not be converted.</strong><strong>But this would, though</strong>
Because not all <strong> tags have a <br /> it's kind of confusing for our users. This could also be the case for more tags ofcourse (<b>, <a>, ...)
There could be 3 solutions:
'/<(strong)( [^>]*)?>(.*?)<\/strong>/si', // <strong>
- Using character classes. Use
[\s\S] instead of . (dot). This would match all characters that are spaces and all characters that are not spaces. In other words, any character, including line breaks. This still gives you the ability to use the . (dot) for it's actual purpose. Not necessary in this case, but giving the option anyways :)
'/<(strong)( [^>]*)?>([\s\S]*?)<\/strong>/i', // <strong>
- Moving the regexp for
<br /> to the end of the array, so <br /> would be converted last.
We have HTML (created by WYSIWYG editors) that contain
<strong>tags with<br />tags inside. Because the<br />tags are converted to new lines before<strong>is being converted to uppercase, and the regexp doesn't match new lines, it prevents the<strong>from being converted to uppercase.Example:
<strong>This would<br />not be converted.</strong><strong>But this would, though</strong>Because not all
<strong>tags have a<br />it's kind of confusing for our users. This could also be the case for more tags ofcourse (<b>,<a>, ...)There could be 3 solutions:
spattern modifier to the regexp (http://php.net/manual/en/reference.pcre.pattern.modifiers.php). This would cause all dots to match line breaks.[\s\S]instead of.(dot). This would match all characters that are spaces and all characters that are not spaces. In other words, any character, including line breaks. This still gives you the ability to use the.(dot) for it's actual purpose. Not necessary in this case, but giving the option anyways :)<br />to the end of the array, so<br />would be converted last.