REGEXP and memory

Just starting out? Need help? Post your questions and find answers here.
loulou2522
Enthusiast
Enthusiast
Posts: 501
Joined: Tue Oct 14, 2014 12:09 pm

REGEXP and memory

Post by loulou2522 »

I work with a string which length is 5222332.
I compile my programm with 64 bits version of purebasic
When i want to extract a great string the system retunr me ba value 0 instead of the real value and i have no errror.
I think i have a memory problem but i don't know how to solve
;

Code: Select all

 Ti load the programm 
 If  ReadFile(0, sxml ,#PB_UTF8)
    FileBuffersSize(0, 1024 )
    toto23.s = ReadString(0,#PB_File_IgnoreEOL)
  EndIf 
and the expression that dosen't work 
  If  CreateRegularExpression(0, "(<PmtInf>).*?(</PmtInf>\s{0,2})",#PB_RegularExpression_DotAll | #PB_RegularExpression_MultiLine)
    Dim resultat$(0)
    Nb = ExtractRegularExpression(0, toto23, Resultat$())
    Debug RegularExpressionError()
   
    If nb=0 
      FreeRegularExpression(0)
      pattern.s =  "(<PmtInf>).*(</PmtInf>\s{0,10}</ CstmrCdtTrfInitn>)"
      CreateRegularExpression(0,pattern, #PB_RegularExpression_DotAll | #PB_RegularExpression_MultiLine)
      Nb = ExtractRegularExpression(0, toto23, Resultat$())
    Else 
      Debug "erreur"
    EndIf 
infratec
Always Here
Always Here
Posts: 6869
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: REGEXP and memory

Post by infratec »

HI, this is a modified version.
If you get the same error, provide a link to such a file.

Code: Select all

EnableExplicit

Define.i nb
Define sxml$, toto23$, pattern$
Dim resultat$(0)

sxml$ = OpenFileRequester("Choose a file", "", "All|*.*", 0)
If sxml$
  
  If ReadFile(0, sxml$, #PB_UTF8)
    toto23$ = ReadString(0, #PB_File_IgnoreEOL)
    
    pattern$ = "(<PmtInf>).*?(</PmtInf>\s{0,2})"
    If CreateRegularExpression(0, pattern$, #PB_RegularExpression_DotAll | #PB_RegularExpression_MultiLine)
      
      Nb = ExtractRegularExpression(0, toto23$, Resultat$())
      FreeRegularExpression(0)
      If nb = 0
        pattern$ =  "(<PmtInf>).*(</PmtInf>\s{0,10}</ CstmrCdtTrfInitn>)"
        If CreateRegularExpression(0, pattern$, #PB_RegularExpression_DotAll | #PB_RegularExpression_MultiLine)
          Nb = ExtractRegularExpression(0, toto23$, Resultat$())
          FreeRegularExpression(0)
          
          Debug "Matches 2: " + Str(nb)
          
        Else
          Debug pattern$
          Debug RegularExpressionError()
        EndIf
      Else
        Debug "Matches 1: " + Str(nb)
      EndIf
      
    Else
      Debug pattern$
      Debug RegularExpressionError()
    EndIf
    
  EndIf
  
EndIf
Post Reply