>>I need to extract the 21 and 22 from this string to get "2122"
>>
>>
>>23^^C4~21^^C4~22^^C4
>>
>>
>>Or it could look like this:
>>
>>
>>23^^C4~22^^C4
>>
>>
>>And I would only want "22"
>>
>>Or this:
>>
>>
>>23^^C4~21^^C4~22^^C4~27^^C4
>>
>>
>>In which case I want "212227"
>>
>>The only truly consistent thing is that there will always be a tilde before the numbers I want.
>
>Hummm, that looks quite tricky. There is no fast and easy answer, you will just have to do some programming <g>.
>
>For a start, at() will give you the position of the tilde. Get the characters after that position with substr(), until the "^" sign - assuming that is consistent. Otherwise, just analyze each of the next characters, adding it to your base string (which should start with the value ""), until you get a character that is NOT a digit. You might use isdigit() for this.
>
>Repeat. See the parameters for at() - there is an option to get the second, third, etc., occurence in a string.
>
>To count from the start how often the "~" appears, use occurs().
>
>HTH,
>
>Hilmar.
Sort of what I ended up doing, but I like Dragan's solution too.
CLEAR
m.ModString = "23^^C4~21^^C4~22^^C4~27^^C4"
m.ModCount = OCCURS('~', m.ModString)
m.Mods = ''
FOR ModLoop = 1 TO m.ModCount
m.Mods = m.Mods + SUBSTR(m.ModString, AT('~', m.ModString, ModLoop) +1, 2)
ENDFOR
? m.Mods