Page 1 of 1

To have numbers only in a phone number column.

Posted: Mon Oct 24, 2011 12:35 pm
by saraswati
Please let me know how we have only numbers for a phonenumber column.

For Example: (304)-645-7865

I just to get the number as 3046457865 .To be more simple, I want only numbers from 0-9 in the phone number column. Eliminate ( ), [], Ext,- etc...

Posted: Mon Oct 24, 2011 1:09 pm
by chulett
On the Server side you have the DIGITS transform but on the PX side I'd just fall back on Convert, I do believe:

Code: Select all

Convert("()[]-. ","",YourField)
Something much like that.

Posted: Mon Oct 24, 2011 1:16 pm
by saraswati
I don't what all non-numeric characters might come so it will be better if we can have some transformation so that it contains only numbers from 0-9.

Posted: Mon Oct 24, 2011 1:17 pm
by arunkumarmm
I'm not sure if there's a function in parallel but if you can use a BASIC_Transformer, you can use Oconv('String',"MCN") to just get the numbers alone from your string.

Posted: Mon Oct 24, 2011 1:25 pm
by chulett
That would be the DIGITS transform I noted.

Posted: Mon Oct 24, 2011 1:27 pm
by chulett
saraswati wrote:I don't what all non-numeric characters might come so it will be better if we can have some transformation so that it contains only numbers from 0-9.
OK. If you are expecting complete crap in your phone numbers then the old "double convert" trick may be in order:

Code: Select all

Convert(Convert("0123456789","",YourField),"",YourField)

Posted: Mon Oct 24, 2011 1:31 pm
by saraswati
You mean to say by using

Convert(Convert("0123456789","",YourField),"",YourField)

if the input value is (879)-986-5623 [5421] then I will get the output as

87998656235421.

RIGHT?????

Posted: Mon Oct 24, 2011 2:47 pm
by max.madsen
Right..
The solution its very interesting..

Posted: Mon Oct 24, 2011 3:02 pm
by saraswati
Thanks a lot....it worked fine.

Posted: Mon Oct 24, 2011 8:27 pm
by chulett
max.madsen wrote:The solution its very interesting..
Yes, it is. I was quite impressed the first time I saw this posted as it wasn't something that had occured to me to do. Basically, the first convert removes all of the characters you want to keep from your string, generating a custom list of all of the unwanted characters in that particular value and that output is used in the next convert to remove them. 8)

Posted: Mon Oct 24, 2011 10:38 pm
by stuartjvnorton
saraswati wrote:Convert(Convert("0123456789","",YourField),"",YourField)
Nicely done. :-)

Posted: Tue Oct 25, 2011 6:42 am
by chulett
You're welcome. :wink: