string manupilation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there a receive a string from a recordset which contains a telephone
number.

It looks like: (03) 9888 5566

How can I manipulate the string, so that the () are deleted.

It should look like this: 03 9888 5566

I also receive a string which contains a mobile number. There should be
another empty space.

It looks like: 0407 566454

But it should look like 0407 566 454

I can't work it out. It drives me nuts :-(

Thanks for your help

Chris
 
Your first question:

newNumber = oldNumber.Replace("(","").Replace(")","");

And for your second, if you're positive that the incoming string is always
formatted like you have it, then just use

newNumber = oldNumber.Substring(0,8) + " " + oldNumber.Substring(8);

Dale Preston
MCAD, MCDBA, MCSE
 
Thank you Dale. This is amazing.

Cheers

Chris

Dale Preston said:
Your first question:

newNumber = oldNumber.Replace("(","").Replace(")","");

And for your second, if you're positive that the incoming string is always
formatted like you have it, then just use

newNumber = oldNumber.Substring(0,8) + " " + oldNumber.Substring(8);

Dale Preston
MCAD, MCDBA, MCSE
 
Back
Top