|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-12-26 19:54 UTC] felipe@php.net
[2008-12-26 20:02 UTC] felipe@php.net
[2008-12-27 16:08 UTC] victor at casnt dot ro
[2008-12-27 22:31 UTC] scottmac@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 17:00:01 2025 UTC |
Description: ------------ The exact same pattern matching is not working on the same string, with a extra line at the end. The length of the string seems to be the problem. Reproduce code: --------------- The script: $handle = fopen('test3.xml', "r"); $contents = fread($handle, filesize('test3.xml')); fclose($handle); $contents = preg_replace('/\>[\t|\ |\s]{1,}\</', "><", $contents); $contents = preg_replace('/\n/', "", $contents); if(preg_match('/(\<\?xml.{1,}\<report[^>]{1,}\>)/', $contents, $match)) { print "Match: $match[1]\n"; } else {print "Fail\n";} OBSERVATION: If you delete the last line from the file test3.xml, the pattern matching will work fine. The last lines have nothing to do with the pattern. You can find the file here: http://www.casnt.ro/Files/XML/test3.xml Expected result: ---------------- Match: <?xml version="1.0" encoding="utf-8"?><report AppKey="CNAS-v1.0.2801.665" AppID="14" clinic="SSSSSSSSSSSSSSSSSSSSSS" fiscalCode="11111111" contractNo="123123123/2008" insuranceHouse="CAS-NT" reportingDate="2008-12-07" startFrom="2008-11-01" endTo="2008-11-30" invoiceNo="" labValue="0" hspValue="0" xmlns="http://localhost"> Actual result: -------------- Fail