Req #77744 [NEW]: Add preg_match flag to return only offsets

From: Date: Thu, 14 Mar 2019 18:39:18 +0000
Subject: Req #77744 [NEW]: Add preg_match flag to return only offsets
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219967@lists.php.net to get a copy of this message
From: cananian at wikimedia dot org Operating system: PHP version: 7.3.3 Package: PCRE related Bug Type: Feature/Change Request Bug description:Add preg_match flag to return only offsets Description: ------------ When creating a high-performance lexer (for example, an HTML5 parser), it is worthwhile to try to avoid the number of string copies made. You can perform matches using offsets into your master source string. However, preg_match will copy a substring for the entire matched region ($matches[0]) as well as for all captured patterns. This can get expensive if the matched region/captured patterns are very large. It would be helpful if PHP's preg_match* functions offered a flag, say PREG_LENGTH_CAPTURE, which returned the numeric length instead of the string. In combination, PREG_OFFSET_CAPTURE|PREG_LENGTH_CAPTURE would return the numeric length in element 0 and the offset in element 1, and avoid the need to copy the matched substring unnecessarily. -- Edit bug report at https://bugs.php.net/bug.php?id=77744&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77744&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77744&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77744&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77744&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77744&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77744&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77744&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77744&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77744&r=support Expected behavior: https://bugs.php.net/fix.php?id=77744&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77744&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77744&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77744&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77744&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77744&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77744&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77744&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77744&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77744&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77744&r=mysqlcfg

« previous php.bugs (#219967) next »