#22366 [Com]: PREG_OFFSET_CAPTURE produces error with preg_match_all

From: Date: Fri, 31 Oct 2003 05:48:16 +0000
Subject: #22366 [Com]: PREG_OFFSET_CAPTURE produces error with preg_match_all
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-49727@lists.php.net to get a copy of this message
ID: 22366 Comment by: ewvea3dgc7001 at sneakemail dot com Reported By: csaba at alum dot mit dot edu Status: Bogus Bug Type: PCRE related Operating System: Win 2K PHP Version: 4.3.0 New Comment: Take the following code: $term_regex='\<td\>\<font face\="verdana,sans-serif" size\=1\>&nbsp;(.*?)\</td\>.\<td\>&nbsp;\<a href\="(.*?)"\>\<font face\="verdana,sans-serif" size\=1 color\=#000000\>(.*?)\</a\>\</td\>.\</tr\>'; preg_match_all("|$term_regex|ms", $snoopy->results, $m, PREG_OFFSET_CAPTURE ); print_r($m); ---- this results in: <b>Warning</b>: Wrong value for parameter 4 in call to preg_match_all() in <b>c:\local\htdocs\ov_tool\tool.php</b> on line <b>26</b><br /> When changed to either of the other 2 int flags it matches fine. This is a valid bug!! PHP 4.3.2, Apache 1.3.29, WinXP Pro Previous Comments: ------------------------------------------------------------------------ [2003-10-31 00:45:04] ewvea3dgc7001 at sneakemail dot com This is in status of "Bogus" and it is not bogus. PREG_OFFSET_CAPTURE does *NOT* work with win2k as of the latest 4.3.2 build. Something is goobered with it. ------------------------------------------------------------------------ [2003-02-23 02:52:13] sniper@php.net When you use preg_match_all() with only 3 paramaters, then PREG_PATTERN_ORDER is assumed for order flag. ------------------------------------------------------------------------ [2003-02-21 17:01:39] csaba at alum dot mit dot edu The following code gives me an error message of: Wrong value for parameter 4 in call to preg_match_all() ... if I replace the PREG_OFFSET_CAPTURE with either PREG_OFFSET_CAPTURE | PREG_SET_ORDER or PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER then it works as advertised. This contradicts the documentation statement: If no order flag is given, PREG_PATTERN_ORDER is assumed $page = "<html><head></head><body><form>" . "<input onClick='alert(\"Hi Mom\")' " . "value='Click me'>" . "<input onClick='alert(\"Hi Dad\")' " . "value=\"Dad's button\">" . "</form></body></html>"; $regexp = "/<input[^>]*(value=[^>]*)>/"; if (!preg_match_all($regexp, $page, $mtch, PREG_OFFSET_CAPTURE)) print "<br>Could not match"; else print "<br>Found matches"; This is on my PHP 4.3.0 / Apache 2.0.43 / Win 2K Pro system Csaba Gabor from New York ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22366&edit=1

« previous php.bugs (#49727) next »