Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99442 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84913 invoked from network); 7 Jun 2017 20:03:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2017 20:03:35 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.192.176 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.192.176 mail-pf0-f176.google.com Received: from [209.85.192.176] ([209.85.192.176:36852] helo=mail-pf0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/49-27119-61C58395 for ; Wed, 07 Jun 2017 16:03:35 -0400 Received: by mail-pf0-f176.google.com with SMTP id x63so9168370pff.3 for ; Wed, 07 Jun 2017 13:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=gusgr28DmU/k9IvvZAReyBe2tsg2C550pTKo6yLmDPQ=; b=WfRNHslLSdwyIuD12JezmrjFp+9yr2TQFztEtWTqfO7z7tSJo1VxVohmUBAROEGEU2 cWSE/DXqo//VKwE5PSL9KaVSYorxTOTpNPyW3YnwDhPlo6XgSWmsNk3nkHiyWp9wvu5j WLQe6ezzqjpoK/r8E+B+KSi7fkZ/JzFF8ahkmcexsTO1yhYuGbRAr5ApV2JYNSo2I8IG +2RCiuhedXkE1z1ypIJvtVX6YhkV7CVdC2eEtkY+dwd1kW3ia0WgG20uYQu7TeFsguwE Qxfx6AoKFDjGwIZyB+9fEQWJqOmU91szAXsIybNWoRsfpUkmZHTICrkdw0yRyG5JBW4E q+ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gusgr28DmU/k9IvvZAReyBe2tsg2C550pTKo6yLmDPQ=; b=feOuXz8BVdgXx2qP8v44PFvravrGRUdJtNv2Wu4RoVHEzoP8fFlPJgULaKT0ZsoAYN 9QyvaoppgK/Aai3+Xhhylq3uYVGAzRhjgCOWWWq6CGIPfn2cj51epUvraZ1CBI6tbZVj 2kSypzSCp+vRdJ3XxKYqWuXEEcp29PoI1NmZNZ6FT7LC1bHJTqsW03hkVGX5igpx+JUW rU0KvAsxut2RvnStSoRXV0I7oQCIsYSzL2nNNmlbEougMI8Ekt3cjlbE+LAovapHZZTL 75/sfAiQ3TtP3egv2SqkUSFXQ5R9JP557reaJ5B3ibfZogSY7pWQY/yY1Gl7y94NDhPq uT4A== X-Gm-Message-State: AODbwcATV9L+wH+wf6KIkZe5sL5Qyc4M9LfLHyC81JCrejxVCBohDqGY rRWcKwRxAly4s8qyadDGvjUNC9OkW8b19wAo9A== X-Received: by 10.98.58.217 with SMTP id v86mr9396485pfj.115.1496865811640; Wed, 07 Jun 2017 13:03:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.131.23 with HTTP; Wed, 7 Jun 2017 13:03:31 -0700 (PDT) Date: Wed, 7 Jun 2017 22:03:31 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="94eb2c11350cfabf040551643a46" Subject: preg_match() option for anchored offset? From: rasmus@mindplay.dk (Rasmus Schultz) --94eb2c11350cfabf040551643a46 Content-Type: text/plain; charset="UTF-8" What do you think about adding another option to preg_match() to allow the $offset parameter to be treated as the start anchor? The manual proposes to do this: $subject = "abcdef"; $pattern = '/^def/'; $offset = 3; preg_match($pattern, substr($subject, $offset), $matches); In other words, use substr() to copy the entire remainder of the string. I just wrote a simple SQL parser tonight, and had to use this approach, which (I imagine) must be pretty inefficient? I'd like to be able to do the following: $subject = "abcdef"; $pattern = '/^def/'; $offset = 3; preg_match($pattern, $subject, $matches, PREG_ANCHOR_OFFSET, $offset); This new option would make the ^ anchor work from the given $offset, which allows me to parse the entire $subject without copying anything. Thoughts? --94eb2c11350cfabf040551643a46--