You are correct that the documentation for REGEXPR is kind of confusing but I'm pretty sure that you can't put that plus sign after the closing parenthesis. It definitely says that plus cannot be used with tags and parenthesis denote tags. Unfortunately, it also says "one or more matches of the preceding sub-pattern" but I'm pretty sure they meant character class.
By the way, by using a space at the end of your mask, if IA=42 appeared at the end of your string with no trailing space, the REGEXPR would never find that particular value. You would need to add a |$ to the end of the mask to match either a space or an end of line character/end of string. You also don't need the parenthesis as you never reference that tag again using \01 later in your mask and you aren't grouping together a multi-character match to use with the OR operator.
If you use a mask of "IA=[0-9]+ |$", you would need to loop like this to get all the values:
Code:
sText = "AZ=1 AZ=5 DE=8 HI=5 HI=9 IA=5 IA=6 IA=11 NY=1 NY=4 WI=3 WI=8 " lIndex = 1 DO REGEXPR "IA=[0-9]+ |$" IN sText AT lIndex TO lStart, lLength IF lStart > 0 THEN ' MID$(sText, lStart, lLength) will contain the first IA=n after lIndex MSGBOX MID$(sText, lStart, lLength) lIndex = lStart + lLength END IF LOOP UNTIL lStart = 0
Code:
sText = "AZ=1 AZ=5 DE=8 HI=5 HI=9 IA=5 IA=6 IA=11 NY=1 NY=4 WI=3 WI=8 " FOR lIndex = 1 TO PARSECOUNT(sText, $SPC) sTemp = PARSE$(sText, lIndex) IF LEFT$(sTemp, 3) = "IA=" THEN ' VAL(MID$(sText, 4)) is the value MSGBOX sTemp END IF NEXT lIndex
Code:
sText = "AZ=1 AZ=5 DE=8 HI=5 HI=9 IA=5 IA=6 IA=11 NY=1 NY=4 WI=3 WI=8 " lStart = INSTR(sText, "IA=") lTemp = INSTR(-1, sText, "IA=") lEnd = INSTR(lTemp, sText, $SPC) IF lEnd = 0 THEN lLength = LEN(sText) - lStart + 1 ELSE lLength = lEnd - lStart END IF MSGBOX MID$(sText, lStart, lLength)
Leave a comment: