note 101090 added to function.preg-match

From: Date: Thu, 25 Nov 2010 13:20:59 +0000
Subject: note 101090 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-174350@lists.php.net to get a copy of this message
I have a problem with multiline matching of .* not being as greedy as it should be. If I use: preg_match("/([^\n\r,]+)[\n\r,](.*)/ms", $addr,$out) The second parenthesis-expression containing the ".*" should surely match to the end of a multiline string. Instead it just seems to match to the next newline - or something similar. The idea was that the $1 parameter contains the first part of the string up to the first newline or comma, while $2 contains the rest. I can work around it but I don't see why it doesn't work. Is this a bug? ---- Server IP: 69.147.83.197 Probable Submitter: 217.41.17.90 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/101090 Del: integrated -- https://master.php.net/note/delete/101090/integrated Del: useless -- https://master.php.net/note/delete/101090/useless Del: bad code -- https://master.php.net/note/delete/101090/bad+code Del: spam -- https://master.php.net/note/delete/101090/spam Del: non-english -- https://master.php.net/note/delete/101090/non-english Del: in docs -- https://master.php.net/note/delete/101090/in+docs Del: other reasons-- https://master.php.net/note/delete/101090 Reject -- https://master.php.net/note/reject/101090 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174350) next »