Page 1 of 1

Preserving part of a token

Posted: Thu Apr 23, 2015 12:48 am
by U
We are seeking to standardize phone numbers, which sometimes have an international direct dialling prefix (001 or 011) as part of a contiguous string.

Is there some way in PAL that we can extract these digits and keep only the remainder?

For example, assuming a wholly numeric token, 00161299556022, the IDD code is 011, the country code is 61, the area code is 2 and the remainder is the line number, and may have variable length (6-8 digits).

We can extract the first three digits using something like [1](1:3) but how can we keep the remainder, the length of which is variable?

Thank you for your time.

Posted: Thu Apr 23, 2015 3:36 am
by ray.wurlod
The substring operator is generous in that you can specify an ending position beyond the end of the token and it will return only up to the end of the token. In your case, something like the following should work, assuming a numeric token.

Code: Select all

; Numeric token beginning 001 or 011 - remove IDD code from front
^ [ {}(1:3) = "001" | {}(1:3) = "011" ]
COPY [1](1:3) {IDDCode}
COPY [1](4:99) temp
RETYPE [1] ^ temp temp

Posted: Thu Apr 23, 2015 9:34 pm
by U
That works well, thank you.

Can something similar be done with other token types (principally &)?

Posted: Fri May 08, 2015 3:55 pm
by ray.wurlod
Should be OK. Try it.