Start a new topic

Replace a character in a string

I want to replace the letter "O" in a zip code/postal code with the number zero as long as it isn't the only character on the line.  (If it is the only character I'm going to replace it with a blank.) 


I can search for (.+)[O](.+) or (.+)[o](.+)


What I can't figure out is how to ut the number zero into the replace string.


Thanks,

1 Comment

Sandy, here is how I would approach it - note: this is NOT tested, it is simplistic (i.e. no defensive or error checking) and is one of may ways to accomplish. "zz" is whatever column your zipcode data is coming from/to


'if the zip code length is 1 char then blank it else sub ohs (O) for zeros(0)

if len(import.fields.getbyexcelname("zz").value)=1 then

     import.fields.getbyexcelname("zz").value=""

else

 import.fields.getbyexcelname("zz").value=replace( import.fields.getbyexcelname("zz").value,"O","0")

end if


Cheers, Dennis

Login to post a comment