ted_chou12 Posted November 17, 2008 Share Posted November 17, 2008 How do you use preg_match to match <p>texts<tags>....</p> with tags inside? Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/133024-solved-preg-match/ Share on other sites More sharing options...
genericnumber1 Posted November 17, 2008 Share Posted November 17, 2008 What's wrong with something simple like <p>(.+?)</p> ? Or, for a more general purpose solution, <([a-zA-Z]+).*?>(.+?)</\1> ? I guess I'm not quite understanding the question. Quote Link to comment https://forums.phpfreaks.com/topic/133024-solved-preg-match/#findComment-691873 Share on other sites More sharing options...
ddrudik Posted November 17, 2008 Share Posted November 17, 2008 ted_chou12, if you want to match nested/non-nested <p>...</p> blocks: preg_match_all('~<p>(??>(??!</?p>).)+)|(?0))*</p>~is',$yourstring,$matchesarray); Quote Link to comment https://forums.phpfreaks.com/topic/133024-solved-preg-match/#findComment-691986 Share on other sites More sharing options...
ted_chou12 Posted November 17, 2008 Author Share Posted November 17, 2008 Thanks, I will try them! Quote Link to comment https://forums.phpfreaks.com/topic/133024-solved-preg-match/#findComment-692050 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.