我有HTML內容的字符串。PowerShell代碼中查找和替換字符串
我想找到幾個字符,與其他一些字符串替換。
對於如:
$Content = "This is my string. For more information, goto http://www.example.com/searchpage.htm. You will get the required information here. You can also get information at http://www.example.com/searchpage1.htm. Do not replace sample.htm. Do not replace sample1.htm."
無論我發現文本example.com
,我需要example1.com
更換和相同的URL包含.htm
,應使.html
如果URL中不包含的例子。 COM,我不想取代的.htm 下面的代碼,我可以實現更換example.com 某些部分,但我不能在同一個UR,以取代部分名爲.htm L.
我不想更換的.htm各地的主要內容。 我只是想取代.htm
無論我更換example.com
$find = "http://www.example.com/"
$newContent = "http://www.example1.com/"
$replacedContent = $Content -replace $strFind,$strReplace
我想知道如何更換文本的多個部分中的長字符串。
請建議!
'-replace '\ bexample \ .COM \ B','例1。 com'' –