>Hi everyone,
>
>For APN I have this format:
>999999X-X999999X-X999999XX-XX999999X-XXXXXX,
>
> where 9 is a digit,
> X as upper case alpha,
> and - is hyphen.
>
>I have an UDF, which determines, is APN valid by inspecting each character. I'm just curious, is there more elegant and simple solution (and should be faster, of course)?
>
>Thanks in advance.
Hi Nadya,
I think the code below does what you want in the generic way.
It certainly can be improved but i'll live it to you :)
lcMask = "999999X-X999999X-X999999XX-XX999999X-XXXXXX"
lcAPN = "123456A-B789012C-D345678EF-GH901234I-KLMNOP"
lcDigits = "0123456789"
lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lcMaskUniform = CHRTRAN( lcMask, lcDigits, REPLICATE("0", 10))
lcMaskUniform = CHRTRAN( lcMaskUniform, lcLetters, REPLICATE("A", 26))
lcAPNUniform = CHRTRAN( lcAPN, lcDigits, REPLICATE("0", 10))
lcAPNUniform = CHRTRAN( lcAPNUniform, lcLetters, REPLICATE("A", 26))
RETURN lcAPNUniform = lcMaskUniform
--sb--