It is currently Wed Oct 21, 2020 3:28 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: REGEXP and memory
PostPosted: Sat Sep 26, 2020 7:11 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Oct 14, 2014 12:09 pm
Posts: 299
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:
 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


Top
 Profile  
Reply with quote  
 Post subject: Re: REGEXP and memory
PostPosted: Sun Sep 27, 2020 9:12 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4963
Location: Germany
HI, this is a modified version.
If you get the same error, provide a link to such a file.
Code:
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 53 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye