Page 1 of 1

ERROR: regular expression is too large

Posted: Fri May 10, 2024 12:23 pm
by Cyllceaux
I create a regular expression:

Code: Select all

#REGEX_NAME="([A-Z]+[A-Z_]*[\d]*){1,250}"
Procedure createRegEx(value.s)
	Protected result=CreateRegularExpression(#PB_Any,value,#PB_RegularExpression_NoCase)		
	If Not IsRegularExpression(result)
		DebuggerError(RegularExpressionError())
	EndIf
	ProcedureReturn result
EndProcedure
		
Global regexCreateSchema=createRegEx("^create schema (?<schema>"+#REGEX_NAME+");?$")		
Global regexCreateTable=createRegEx("^create table ((?<table>"+#REGEX_NAME+")\.)?(?<schema>"+#REGEX_NAME+");?$")		
Now I get the error:
regular expression is too large
I didn't know there is a max length for an expression.

Then I trying something and find out. This error only appears with the PB_RegularExpression_NoCase flag.
Is this a bug or missing documentary?

Re: ERROR: regular expression is too large

Posted: Fri May 10, 2024 12:51 pm
by Cyllceaux
I played a little bit:

Code: Select all

#REGEX_NAME="([A-Z]+[A-Z_]*[\d]*){1,250}"
Procedure createRegEx(value.s)
	Protected result=CreateRegularExpression(#PB_Any,value)		
	If Not IsRegularExpression(result)
		DebuggerError(RegularExpressionError())
	EndIf
	ProcedureReturn result
EndProcedure

;Global regexCreateTable=createRegEx("^(?i)create table ((?<table>"+#REGEX_NAME+")\.)?(?<schema>"+#REGEX_NAME+");?$") ; Same Error
Global regexCreateTable2=createRegEx("^(?i)create table(?-i) ((?<table>"+#REGEX_NAME+")\.)?(?<schema>"+#REGEX_NAME+");?$") ; no error
it looks like the regex-lib had some problems with NoCase in some special circumstances.

Re: ERROR: regular expression is too large

Posted: Fri May 10, 2024 1:03 pm
by Cyllceaux

Code: Select all

#REGEX_NAME="([A-Z]+[\w]*[\d]*){1,250}"
#REGEX_NAME2="([A-Z]+[A-Z_0-9]*[\d]*){1,250}"
#REGEX_NAME3="([A-Z]+[A-Z_]*[\d]*){1,250}"


Debug CreateRegularExpression(#PB_Any,"^create table ((?<table>"+#REGEX_NAME+")\.)?(?<schema>"+#REGEX_NAME+");?$",#PB_RegularExpression_NoCase) ; OK
Debug CreateRegularExpression(#PB_Any,"^create table ((?<table>"+#REGEX_NAME2+")\.)?(?<schema>"+#REGEX_NAME2+");?$",#PB_RegularExpression_NoCase) ; NOK
Debug CreateRegularExpression(#PB_Any,"^create table ((?<table>"+#REGEX_NAME3+")\.)?(?<schema>"+#REGEX_NAME3+");?$",#PB_RegularExpression_NoCase) ; NOK
I think it's not a bug in pb but in the regex-lib

Re: ERROR: regular expression is too large

Posted: Fri May 10, 2024 4:10 pm
by DarkDragon
Why do you need 1,250? That's an insanely large NFA and converted to DFA even larger. Use + instead?

Re: ERROR: regular expression is too large

Posted: Fri May 10, 2024 6:45 pm
by AZJIO
{1,235}