note 35124 deleted from function.preg-match by aidan

From: Date: Sat, 07 Aug 2004 17:07:16 +0000
Subject: note 35124 deleted from function.preg-match by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74147@lists.php.net to get a copy of this message
Note Submitter: plenque@hotmail.com ---- I wrote a function that checks if a given regular expression is valid. I think some of you might find it useful. It changes the error_handler and restores it, I didn't find any other way to do it. Function IsRegExp ($sREGEXP) { $sPREVIOUSHANDLER = Set_Error_Handler ("TrapError"); Preg_Match ($sREGEXP, ""); Restore_Error_Handler ($sPREVIOUSHANDLER); Return !TrapError (); } Function TrapError () { Static $iERRORES; If (!Func_Num_Args ()) { $iRETORNO = $iERRORES; $iERRORES = 0; Return $iRETORNO; } Else { $iERRORES++; } }

« previous php.notes (#74147) next »