Friday, 15 June 2012

Powershell Reg exp and replace a part of it -



Powershell Reg exp and replace a part of it -

i have line in file 3875-01-12t04:30:00z wanna replace t***z string null.

please not string between t , z can diferent, need string within t , z , replace it.

thanks in advance

$result = $subject -creplace 't[\d:.]*z', ''

should do. added dot in case encounter times more precise seconds.

if want create sure t...z deleted if follows yyyy-mm-dd string, use

$result = $subject -creplace '(?<=\d{4}-\d{2}-\d{2})t[\d:.]*z', ''

powershell

No comments:

Post a Comment