Jump to content

You think you can write regex?


James
 Share

Recommended Posts

  • Administrators

I got it to compile by changing this config:


PCRE_CONFIG_LINK_SIZE

The output is an integer that contains the number of bytes used for
internal linkage in compiled regular expressions. For the 8-bit
library, the value can be 2, 3, or 4. For the 16-bit library, the value
is either 2 or 4 and is still a number of bytes. For the 32-bit
library, the value is either 2 or 4 and is still a number of bytes. The
default value of 2 is sufficient for all but the most massive patterns,
since it allows the compiled pattern to be up to 64K in size. Larger
values allow larger regular expressions to be compiled, at the expense
of slower matching.

 

But as it mentions slower matching I'll leave it as is.

Link to comment
Share on other sites

Yeah, it's a crazy regex and would probably never be performed IRL. But like Mat suggested, the limitation should be documented :)

Out of interest Jon, how much slower is it compiling a normal regex by using the PCRE_CONFIG_LINK_SIZE setting? If it's negligible for average regular expressions, wouldn't it be good to leave on for the big'ns?

Edited by James
Link to comment
Share on other sites

From ealier experiments, leave the link_size at its default of 2. Compilation and matching are much slower if this parameter is changed, due to sub-optimal internal code generation. My tests were at the time where only PCRE8 existed (UTF-8) so I don't know how it affects current library.

Anyway, the default is large enough for any reasonable pattern in real-world application IMHO.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Update: Pillip Hazel (PCRE author) just confirms that with linksize = 2, PCRE hits its internal limit of 64K while reaching 1589395 bytes of pattern (short 1599858 - 1589395 = 10463 pattern bytes only!) on his Linux box.

What that means is that we're fairly close to be able to handle regexps that large including an enormous number of non-capturing groups and alternations. Therefore I don't see the need to bump to linksize 3 as we would incur pointless penalty in real-world uses.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Administrators

For the 16bit version of pcre you can only use link=2 or 4 anyway.  That number 1589395 is similar to the @error/@extended value in my orginal script - so that makes sense.

Link to comment
Share on other sites

Yes I meant 4. Not yet used to pcre16 myself.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • 1 month later...
  • Administrators

I also have regexpbuddy but it sucks by not supporting many features and clearly author completely lost interest years ago.

Spooky, it just got updated. Looks the same but works in high DPI mode and apparently lots of backend changes.

Link to comment
Share on other sites

Yup, I saw that but I question the need to "paywarely" update.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...