vbscript - Regex to insert space after every 4 characters? -


using vbscript 5.5 regex, how can replace string there's space after every 4 characters?

i tried following doesn't work:

dim rex new regexp  rex.ignorecase = true rex.global = true rex.pattern = ".{4}"  dim newstring string newstring = trim$(rex.replace(trim$(inputstring), "$0 ")) 

you need group () , better ref ($1):

>> set r = new regexp >> r.global = true >> r.pattern = "(.{4})" >> wscript.echo r.replace("1234567890123", "$1 ") >> 1234 5678 9012 3 >> 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -