Tuesday, 15 June 2010

regex - Convert String to e-mail address -



regex - Convert String to e-mail address -

i writing script rename exported pst files match format needed import new system.

i trying utilize regular look in vbscript along replace.

an illustration string:

joebloggs_export_001.pst

required end result:

joe.bloggs@emaildomain.com._001.pst

i have got replace of export @emaildomain.com. working replace.

i struggling insert of . between first-name , last-name, figured using regular look best approach. struggling getting work. length of first-name varies.

i have tried various regular expressions, rather sharing of these hoping getting fresh set of eyes help highlight have been going wrong.

many in advance.

mark

assuming want break pascal cased name on caps can capture lower-case followed upper-case & insert ".";

set re = new regexp re.pattern = "([a-z])([a-z])" re.global = true filename = "joebloggs_export_001.pst" msgbox replace(re.replace(filename, "$1.$2"), "_export_", "@emaildomain.com._") >> joe.bloggs@emaildomain.com._001.pst

regex vbscript

No comments:

Post a Comment