Why PCRE instead of PCRE2?

Discuss the future of the AutoHotkey language
Posts: 145
Joined: 08 Dec 2014, 22:13

Why PCRE instead of PCRE2?

12 Jun 2018, 14:31

From the documentation, I understand that AHK has implemented PCRE. Curious why AHKv2 is not using PCRE2 since I've found several AHK posts about desired features like regex global matching and some of the attempts at workarounds e.g. RegexMatchAll() and a grep solution.

Looking at PCRE's site, is seems PCRE2 has features like regex global matching?
Finding all matches in a string
Searching for all possible matches within a subject can be requested by the global or altglobal modifier. After finding a match, the matching function is called again to search the remainder of the subject. The difference between global and altglobal is that the former uses the start_offset argument to pcre2_match() or pcre2_dfa_match() to start searching at a new point within the entire string (which is what Perl does)...
Just wondering
Posts: 6379
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Why PCRE instead of PCRE2?

12 Jun 2018, 19:09

Let me answer that with a question: Why PCRE2 instead of PCRE?

We don't need PCRE2 to perform global matching; we can just call the matching function in a loop, just like PCRE2 does according to your quote. RegExReplace already does this. The reason we don't have a global matching function built-in is that none of the developers cared to add it. It is easy enough to use RegExMatch in a loop - these are not "attempts at workarounds", but perfectly valid solutions to a problem.

Rather than "Why PCRE instead of PCRE2?", the question is really "Why hasn't the version of PCRE used by AutoHotkey been updated?". The answer is, again, that none of the developers cared to do it.

By "developers", I mean anyone with the will to make a contribution of that nature. Personally, I never even considered updating to PCRE2, because I'm not aware of any reason to do so and have no interesting in finding one.

The reason PCRE2 is not just "PCRE version 10" is that its API is not compatible. It isn't just a case of dropping in the PCRE library and making use of the new features; any code dealing with PCRE has to be updated.
Posts: 145
Joined: 08 Dec 2014, 22:13

Re: Why PCRE instead of PCRE2?

13 Jun 2018, 00:24

Thanks for your response - and for the education. And many thanks for all your work regarding the amazing autohotkey.

I tend to use RegexBuddy to develop & test my regexes. Is "PCRE 8.40-8.42 UTF-8" the correct selection for compatibility with AHK?
Posts: 2519
Joined: 11 Jan 2017, 17:59

Re: Why PCRE instead of PCRE2?

13 Jun 2018, 03:22

8.30 is what ahk uses, last time I checked.
User avatar
Posts: 6395
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Why PCRE instead of PCRE2?

13 Jun 2018, 03:24

- From the AHK changelog:
Changes & New Features
https://autohotkey.com/docs/AHKL_ChangeLog.htm - July 14, 2012
Upgraded PCRE to 8.30.
- From the AHK source code, in pcre.h:

Code: Select all

/* The current PCRE version information. */

#define PCRE_MAJOR          8
#define PCRE_MINOR          30
#define PCRE_DATE           2012-02-04
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Posts: 145
Joined: 08 Dec 2014, 22:13

Re: Why PCRE instead of PCRE2?

13 Jun 2018, 04:39

Thanks folks
Posts: 97
Joined: 28 Sep 2016, 11:14

Re: Why PCRE instead of PCRE2?

15 Apr 2019, 10:03

I totally get why we're sticking with PCRE1 — everyone's code would break.

One question, though. On the PCRE1 branch, there have been a lot of bug fixes since version 8.30 (Feb 2012) that AHK is on. This table summarizes nicely the changes between PCRE versions, while this is the whole boring changelog. We're now on 8.43 (Feb 2019).

I realize it's not a priority, but is there a chance that the PCRE1 inside AHK will be updated to a recent bug-fix in a future release?

Already hugely grateful to have it within AHK anyhow, but wishing the best in terms of reliability. :) One thing that the engine gets better at is aborting early by detecting faulty expressions that might just lock up your program.

Further resources:
Posts: 638
Joined: 15 Jun 2015, 06:21

Re: Why PCRE instead of PCRE2?

15 Apr 2019, 17:57

The PCRE1 vs PCRE2 mini drama also reflects issues involving AHK v1 VS AHK v2. There is a negative cost associated with major updates and revisions of a language (or project), which must be weighed against benefits. If the benefit is calculated as small, then this will understandably cause hesitation or conservatism. A lot of time people want "new", but then not realize the costs, labor, effort, other things needed to be upgraded along with, etc... associated with it. Or, that "new" doesn't always mean "better".

And it seems like if there was an upgrade, it's more likely to be PCRE1 (from 8.30 to 8.43 or whatever at the time) than it is to be PCRE2, if the odds or percentage of scripts breaking will remain low. Lastly, AutoHotkey has so many other functions and workarounds for handling strings, probably 98% of users would never encounter a situation where the difference between PCRE1 and PCRE2 would affect them. Asking to upgrade PCRE1 to the latest version is probably the best that can be hoped for.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 10 guests