Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regular expression "findrx" fails when source string length is 2610 or larger
#1
Hi everybody

I have a bunch of txt files with lines of text (aprox. 30-50 lines)
I use regular expression to get part of the content between two words "Hello" and "Regards", it works fine but some of the files crash due to the content is larger than findrx can handle.

I have spent som time and found the triggering limit is when my string "txtIndex" which contains the data from text file is the lenght of 2610 or more, then I get the error:
"failed: Regular expression stack overflow."


can I expand the memory limit?
Should I use something else than a string to store data from the text file?


My macro is:

Macro getLetterContent
Code:
Copy      Help
str txtIndex.getfile("C:\sampleData.txt")
out len(txtIndex)

str letterContent
int i
str pattern = "(?<=Hello)(.|\n)*(?=Regards)"
i=findrx(txtIndex pattern 0 0 letterContent)
out letterContent
#2
"(?s)(?<=Hello).*(?=Regards)"
or
"(?s)(?<=Hello).*?(?=Regards)"
or
str pattern = "(?s)Hello(.*)Regards"
i=findrx(txtIndex pattern 0 0 letterContent 1)
#3
Gintaras, you are so fast and sharp!
I could not get the two first RegEx options to work, but the last one works no matter how much text I put in the file..

thank you so much! If you ever come to Denmark, you have 100 beers of credit at my house!


Forum Jump:


Users browsing this thread: 1 Guest(s)