I am extracting a nested content of a tag. I have written a regular expression that works perfectly on my local machine (WAMP) PHP Version 5.3.8, Multibyte regex (oniguruma) version - 4.7.1
$tagname = 'mytag';
$pattern = "@<$tagname(?:\s.*?!/)?>(.*?)</$tagname\s*>@s";
but the same regular expression is not working properly on my live machine with configuration of PHP Version 5.2.11, Multibyte regex (oniguruma) version- 4.4.4 and Multibyte regex (oniguruma) backtrack check = on.
Please help in modifying this regular expression that it start work on live site.
This regular expression match <mytag></mytag>
and it is not matching <mytag />
.
Update: Thanks for your suggestions and responses.
I updated that regular expression a bit and it worked for me. You can use this regular expression whenever you want get inner content (nested tags and text). No matter how your tag is arranged and no matter how many attributes it has.