Output a "tab" in PowerShell -


a simple syntax question in powershell.

i've variable $content provides this:

id  name    when    ip  msg user_id 50 felix   2015-07-22 12:51:04 10.1.100.6  "ein link":www.link.de  89 

i process this:

$content -replace '^(.+?)\t"(.+?)"(.+?)$', '$1`t"""$2"$3' 

i this:

id  name    when    ip  msg user_id 50 felix   2015-07-22 12:51:04 10.1.100.6`t"""ein link":www.link.de  89 

but should this:

id  name    when    ip  msg user_id 50 felix   2015-07-22 12:51:04 10.1.100.6   """ein link":www.link.de  89 

i tried \t , ``t nothing gives real tab back.

can me?

this because you're using literal quotes '..' backtick won't treated escape character. instead, use "..." , escape additional " characters backtick:

$content -replace '^(.+?)\t"(.+?)"(.+?)$', "`$1`t`"`"`"`$2`"`$3" 

however, may simpler include tab in first capture group:

$content -replace '^(.+?\t)"(.+?)"(.+?)$', '$1"""$2"$3' 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -