Start a new topic

Replacing leading 0

Hello, 


Would anybody be able to help me create a Reg Expression for replacing the leading 0 of a mobile number with 44 but leaving any other 0's alone?


So 07123456789 would become 447123456789 


Many thanks, 


Laura

1 Comment

My personal preference is not using regex as I generally want to do other things (ex. remove hypens and paran's or who know).  In the 'afterdictionary' section I would;


 'XX is whatever your column name is of the telephone number

if Left(import.fields.getbyexcelname("XX").Value,1)="0" then

  import.fields.getbyexcelname("XX").Value="44"+right(import.fields.getbyexcelname("XX"),2,len(import.fields.getbyexcelname("XX")))

endif


The above basically reads as "if first char of the telephone number is Class is the 0 then make the telephone number 44 plus the remainder of the telephone number minus the 0.  There are different ways to code but think you get the gist.  Note: the above code is not tested or anything else just a quick typing of a possible solution.

Login to post a comment