Powershell GUI正则表达式替换

问题描述

我想在PowerShell ISE中使用正则表达式来替换一行,我确实收到错误消息,但是添加内容确实有效。 $ Filebrowser.FileName 是假定进行此更改的所选文件。如果Get-Content不起作用,如何在这种情况下使regex正常工作?

$editButton = New-Object System.Windows.Forms.Button
$editButton.Add_Click({
If($Filebrowser.FileName -like "*\*") {

Add-Content $Filebrowser.FileName `
    "`ntest"

#This below does not work:
Get-Content $Filebrowser.FileName `
    -replace 'blockquote {.*?}','blockquote {margin-bottom: 4em;}'
     Set-Content $Filebrowser.FileName
    }})

错误消息:

Get-Content : A parameter cannot be found that matches parameter name 'replace'.
At C:\Users\stari\Downloads\Compressed\Den-oändliga-histori CA44282\rest\CSS_ARBETAR MED KLART.ps1:70 char:5
+     -replace 'blockquote {.*?}','blockquote {margin-bot ...
+     ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Content],ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)