Page 1 of 1

small help with regular expressions

Posted: Wed Jul 12, 2006 7:25 am
by jasongr
Hi people

Given a PHP string

How can I use eregi to find out if the string contains any tag that is not <p> or </p>

any help with formatting this pattern will be useful
I am new to regular expressions

thanks

Posted: Wed Jul 12, 2006 7:36 am
by Weirdan
hmm... untested:

Code: Select all

</?[^p][^>]*>

Posted: Wed Jul 12, 2006 8:15 am
by sweatje
Technically

Code: Select all

if ($text != strip_tags($text, '<p>')) { /* must have contained non <p> tags */ }
Should answer the specific question you asked without any regex at all.

Are you really asking a different question?

Posted: Wed Jul 12, 2006 9:04 am
by Oren
Nice way of thinking sweatje... I like that :D
But for you jasongr I suggest to run several tests to see which way is faster.

Posted: Wed Jul 12, 2006 2:41 pm
by R4000
if you need a regexp tester, i find http://www.rexv.org/ works brillientyl