Announcement

Collapse
No announcement yet.

REGEXPR - Limit on length of mask$?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • REGEXPR - Limit on length of mask$?

    I regularly use REGEXPR for confirming the format of a string before processing it...very handy

    I'm working on an enhancement for my recently uploaded app...DrvSpMon

    I made what I thought was a fairly simple change to the mask and suddenly the results started failing. After a lot of head scratching (assuming I messed up the mask)...I started to just shorten it and somewhere between 539 and 599 bytes if begins to fail.

    I can't find anything in the doc that states that the mask$ has a limit on the length

    Anyone else hit their head on this limit?

  • #2
    When in doubt write some code to test it... the short answer is that I must be doing something wrong in my other code

    Here's my test code that shows REGEXPR mask$ growing to over 4K and likely WELL beyond...not tested here

    Back to find issue in original code...SORRY!!

    Code:
    #COMPILE       EXE
    #COMPILER      PBCC 6
    #DIM           ALL
    #OPTIMIZE      SPEED
    #OPTION        VERSION5
    
    FUNCTION PBMAIN()
    
       LOCAL sTest       AS STRING
       LOCAL sRegExpMask AS STRING
       LOCAL dwRegExpPos AS DWORD
       LOCAL dwRegExpLen AS DWORD
       LOCAL X           AS LONG
    
       sTest       = "    Test 123 ABC   Z:   XYZ ..."
       sRegExpMask = "[A-Z]:"
    
       FOR X = 1 TO 600
    
          sRegExpMask += "[A-Z .]?"
    
          TRY
             REGEXPR sRegExpMask IN sTest TO dwRegExpPos,dwRegExpLen
          CATCH
             CON.STDOUT "Error triggered"
          END TRY
    
          CON.STDOUT RSET$(FORMAT$(X),3) + "   " + FORMAT$(dwRegExpPos) + "   " + RSET$(FORMAT$(LEN(sRegExpMask),"#,"),7)
    
       NEXT X
    
    END FUNCTION
    Sample output:
    Code:
      1   20        14
      2   20        22
      3   20        30
      4   20        38
      5   20        46
      6   20        54
      7   20        62
      8   20        70
      9   20        78
     10   20        86
    ...
    591   20     4,734
    592   20     4,742
    593   20     4,750
    594   20     4,758
    595   20     4,766
    596   20     4,774
    597   20     4,782
    598   20     4,790
    599   20     4,798
    600   20     4,806

    Comment

    Working...
    X