note 34323 deleted from function.preg-match-all by didou

From: Date: Thu, 24 Jul 2003 08:39:26 +0000
Subject: note 34323 deleted from function.preg-match-all by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-52541@lists.php.net to get a copy of this message
Note Submitter: andrew __@7__ majiclab __d07__ com ---- In response to remcoman at hotmail dot com's post: I have slightly modified the regexp to work better in a couple ways: Original RegExp: /([a-zA-Z0-9]+)[\s]{0,1}=[\s]{0,1}((\')|"|) ((?:(?:\\\\\\2)|(?(3)[^\']|[^"]))*)(\2)(?:\s|$)/U RegExp: /([\w]+)(?:=((\')|"|)((?:(?:\\\\\\2)|(?(3)[^\']|[^"]))*) (\2))?(?:\s|$)/U The original will match: attr1="valu\"e 1" attr2=value2 attr3='valu\'\\\'e3' all the proper way one would expect. My slightly modified version also accepts: attr_1="valu\"e 1" attr2 Extra programming would have to be done for attributes with no '='. If there is no '=' for a given match, only the 1 match pattern will be returned (name of attribute). Otherwise, all 5? will be returned. -Percy PS: Make sure you put the RegExp on one line if you copy it.

« previous php.notes (#52541) next »