ERROR: regular expression is too large

Just starting out? Need help? Post your questions and find answers here.
Cyllceaux
Enthusiast
Enthusiast
Posts: 514
Joined: Mon Jun 23, 2014 1:18 pm

ERROR: regular expression is too large

Post 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?
Last edited by Cyllceaux on Fri May 10, 2024 12:52 pm, edited 1 time in total.
Cyllceaux
Enthusiast
Enthusiast
Posts: 514
Joined: Mon Jun 23, 2014 1:18 pm

Re: ERROR: regular expression is too large

Post 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.
Cyllceaux
Enthusiast
Enthusiast
Posts: 514
Joined: Mon Jun 23, 2014 1:18 pm

Re: ERROR: regular expression is too large

Post 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
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: ERROR: regular expression is too large

Post by DarkDragon »

Why do you need 1,250? That's an insanely large NFA and converted to DFA even larger. Use + instead?
Last edited by DarkDragon on Fri May 10, 2024 7:59 pm, edited 1 time in total.
bye,
Daniel
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: ERROR: regular expression is too large

Post by AZJIO »

{1,235}
Post Reply