note 33386 added to function.ereg

From: Date: Tue, 24 Jun 2003 18:14:13 +0000
Subject: note 33386 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-50949@lists.php.net to get a copy of this message
I wanted to match zero or more whitespaces in a row, between two strings. Thought this might save somebody some pain: $myVar = "lefttext \n\t \r \n righttext"; The middle is just garbage whitespace, which can be different in different situations (in my case, I'm parsing PDFs for metadata). if(ereg("lefttext( |\n|\t|\r)*righttext",$myVar)) { echo("Validates!\n"); } else { echo("Does NOT validate.\n"); } The working part of the phrase is ( |\n|\t|\r)* - matches zero or more whitespaces. ---- Manual Page -- http://www.php.net/manual/en/function.ereg.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33386 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33386&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33386&report=yes

« previous php.notes (#50949) next »