替换特殊字符?

时间:2014-12-07 02:19:01

标签: powershell replace special-characters

我想将“,< *”替换为“*<”在行的开头和结尾“*>”用“> *”。以下命令无效。请协助。

$inputmatch = ",<*abc*>,<*>,<*abc*>,<*abc*>"     
$inputmatch = $inputmatch -replace "^\,\<\*","\*\<"   
$inputmatch = $inputmatch -replace "\*\>$","\>\*"

1 个答案:

答案 0 :(得分:2)

$inputmatch = ",<*abc*>,<*>,<*abc*>,<*abc*>"    
$inputmatch -replace '^,<\*','*<' -replace '\*>$','>*'

*<abc*>,<*>,<*abc*>,<*abc>*