Jump to content
UBot Underground

Replacing the first zero in a phone number


Recommended Posts

Hi all,

 

 

I am using 4.0 Pro and want to know how this would work for phone numbers

 

I would like to remove the first zero from a phone number and replace it with a country code, for example

 

0443 123 3322

 

I would want to drop the first 0 and replace it with 61 leaving me with

 

61443 123 3322

 

I have the phone number currently inside a variable, called #phone and call upon that variable further on in my bot, so ideally would like to keep the variable name and update the variable value.

 

Thanks in advance!

Link to post
Share on other sites

You can do this using the replace command. For the purpose of this explanation I will explain how to do it in two commands (although ultimately you can do it with one, it's just easier to see in two).

 

set--->#phone(0443 123 3322)

set--->#phone--->$replace(#phone, 044, 6144)

Does that make sense? If not I'll provide the actual code.

John

Link to post
Share on other sites

Hi John,

 

Just getting back to this now

 

Here's what I have

 

http://content.screencast.com/users/koconnor00/folders/Jing/media/a99f9234-7f8c-4671-ac26-4094ba16ab30/2011-12-22_0928.png

 

 

Is this what you meant?

 

Also, I would be concerned should the numbers 07 appear further in the phone number as this could cause a problem with replacing them.

Link to post
Share on other sites

Ok just to update - this replace works well, exactly as I had hoped. Only the issue is if the number 07 appeared more than once in the phone number.

 

So ideally I only want it to replace the first 2 digits. I am assuming now some regex is in order. Any help on this would be great.

Link to post
Share on other sites

Actually, it would be even easier for me if I simply replace the FIRST zero with 44

 

That would actually make this process easier and take into account landline numbers as well as mobile numbers.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...