It is currently March 29th, 2024, 5:24 am

List of RegExp error?

General topics related to Rainmeter.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

List of RegExp error?

Post by mak_kawa »

Is there a list of RegExp matching error from the WebParser measure? I couldn't find it in Rainmeter documents and forums.

For example, what is RegExp matching error (-8)? I suppose it is "Could not match all searches" as far as testing in the RainRegExp.
But I want to see the full list of the "RegExp matching error"...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: List of RegExp error?

Post by jsmorley »

Yes. But you're not going to like it. - Deep Thought, Hitchhiker's Guide

Code: Select all

PCRE_ERROR_NOMATCH				(-1)
PCRE_ERROR_NULL					(-2)
PCRE_ERROR_BADOPTION				(-3)
PCRE_ERROR_BADMAGIC				(-4)
PCRE_ERROR_UNKNOWN_OPCODE			(-5)
PCRE_ERROR_NOMEMORY				(-6)
PCRE_ERROR_NOSUBSTRING				(-7)
PCRE_ERROR_MATCHLIMIT				(-8)
PCRE_ERROR_CALLOUT				(-9)
PCRE_ERROR_BADUTF8				(-10)
PCRE_ERROR_BADUTF16				(-10)
PCRE_ERROR_BADUTF32				(-10)
PCRE_ERROR_BADUTF8_OFFSET			(-11)
PCRE_ERROR_BADUTF16_OFFSET			(-11)
PCRE_ERROR_PARTIAL				(-12)
PCRE_ERROR_BADPARTIAL				(-13)
PCRE_ERROR_INTERNAL				(-14)
PCRE_ERROR_BADCOUNT				(-15)
PCRE_ERROR_DFA_UITEM				(-16)
PCRE_ERROR_DFA_UCOND				(-17)
PCRE_ERROR_DFA_UMLIMIT				(-18)
PCRE_ERROR_DFA_WSSIZE 				(-19)
PCRE_ERROR_DFA_RECURSE				(-20)
PCRE_ERROR_RECURSIONLIMIT			(-21)
PCRE_ERROR_BADNEWLINE				(-23)
PCRE_ERROR_BADOFFSET				(-24)
PCRE_ERROR_SHORTUTF8				(-25)
PCRE_ERROR_SHORTUTF16				(-25)
PCRE_ERROR_RECURSELOOP				(-26)
PCRE_ERROR_JIT_STACKLIMIT			(-27)
PCRE_ERROR_BADMODE				(-28)
PCRE_ERROR_BADENDIANNESS			(-29)
PCRE_ERROR_DFA_BADRESTART			(-30)
PCRE_ERROR_JIT_BADOPTION			(-31)
PCRE_ERROR_BADLENGTH				(-32)
PCRE_ERROR_UNSET				(-33)
And no, I have no idea what almost all of those mean. I guess you could google one, like PCRE_ERROR_MATCHLIMIT, which is -8, and discover that it is basically telling you that something you have created is probably "endlessly recursive", and you have run out of a limit PCRE sets. I would not jump to the conclusion that you have yourself created an endless loop in the expression, PCRE is in and of itself massively "recursive" as it repeatedly looks forward and then backtracks to execute your search. Just having a search "fail", when the expression is designed in such a way that it is loath to stop trying, is enough to get this condition.

Seriously, trying to understand the "internals" of regular expression, how it takes all those rules that are reasonably logical and reasonably simple, and actually executes those on the string in question, is a certain road to perdition. Just read any site that even makes an attempt to describe what is actually going on, and you will soon just start to glaze over.

To be honest, if you get an error code, that just means your regular expression is failing. I don't think the code offers much if anything in the way of debugging help.

You are going to be better off going to one of the many sites that allow you to test regular expressions, like https://regex101.com/ and try it out there. That should at a minimum point to the spot in the expression where it it failing.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: List of RegExp error?

Post by mak_kawa »

Hi jsmorley

Thank you for reply and kind guidance.

Yes, I am still a RegExp noob especially of "assertion". It is just a labyrinth for me... :-) Now I am struggling with weird (of course at least for me) RegExp error(s). Hope I will figure it out reading/googling about RegExp as you suggested.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: List of RegExp error?

Post by jsmorley »

mak_kawa wrote: June 25th, 2020, 1:25 am Hi jsmorley

Thank you for reply and kind guidance.

Yes, I am still a RegExp noob especially of "assertion". It is just a labyrinth for me... :-) Now I am struggling with weird (of course at least for me) RegExp error(s). Hope I will figure it out reading/googling about RegExp as you suggested.
There is just no easy way to debug regular expression. Those error codes are literally of no help. The problem is that "nothing matches" is not an error, it's a perfectly valid answer to the question. The only way to do it is to start small, write a little bit of the expression, test it with RainRegExp or that testing site I linked to. See if it works. If it does, add a bit more.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: List of RegExp error?

Post by mak_kawa »

Hi jsmorley

Testing my RegExp at the regex101.com has ended up with "Catastrophic backtracking"... I am really scared. My RegExp has caused catastrophe... :-)

Anyway, I will examine with a smallest code as a test skin. Thanks, again.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: List of RegExp error?

Post by jsmorley »

mak_kawa wrote: June 25th, 2020, 1:56 am Hi jsmorley

Testing my RegExp at the regex101.com has ended up with "Catastrophic backtracking"... I am really scared. My RegExp has caused catastrophe... :-)

Anyway, I will examine with a smallest code as a test skin. Thanks, again.
Catastrophic is one of my least favorite words in programming... ;-)