Forum Moderators: coopster

Message Too Old, No Replies

find missing tags with preg match all

         

phparion

2:04 pm on Jan 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi

i have strings which is valid when

{i}missing #1 tag {p}"p"{c}{product_price}{/c}{p}2000{/p}{/i}{/p}

but INVALID when

{i}missing #1 tag {p}"p"{c}{product_price}{/c}{p}2000{/p}{/i}

as p tag is missing for the first opening of opening p-tag. this can be true in opposite case when an OPENING p-tag is missing and closing tag is found.

how can i strip out such broken tags?

I cannot use something like

preg_match_all("/\{p\}(.*?)\{\/?p\}",$str,$matches);

coopster

7:17 pm on Apr 20, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Maybe something like the tidy extension would come in handy here?