note 15735 added to function.ereg

From: Date: Fri, 28 Sep 2001 13:50:58 +0000
Subject: note 15735 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-18409@lists.php.net to get a copy of this message
Another useful little program for validating your regex : <?php if(isset($text)) { $regex = "^([[:alnum:]]+)\.(htm|html)$"; echo "regex : $regex<br>\n"; $result = eregi($regex,$text,$out); echo "$text " . (($result) ? "is " : "is not ") . "parsed<br>\n"; if(is_array($out)) { while(list($k,$v)=each($out)) echo "$k $v<br>\n"; } } ?> <form action="test.php" method=post> <input type=text name=text value="<?php echo $text; ?>"> </form> Keep this in a handy file called test.php. Replace the $regex contents with the regex string you are testing and you can then test your ereg statement. It only requires slight extensions to cope with ereg_replace. This may seem a trivial program, but it's better than attempting to debug a single line of regex that is misbehaving in a large and complex system. -- http://www.php.net/manual/en/function.ereg.php http://master.php.net/manage/user-notes.php?action=edit+15735 http://master.php.net/manage/user-notes.php?action=delete+15735 http://master.php.net/manage/user-notes.php?action=reject+15735

« previous php.notes (#18409) next »