I have a test.lua (UTF-8) file:
function private.PostAuctionsThread(self, auctionInfo)
self:SetThreadName("SHOPPING_POST_AUCTIONS")
local auctionRecord = auctionInfo.record
local postFrame = private.frame.content.result.confirmation.post
private.frame.content.result.cancelBtn:Disable()
private.frame.content.result.postBtn:Disable()
private.frame.content.result.bidBtn:Disable()
private.frame.content.result.buyoutBtn:Disable()
postFrame.postBtn:Enable()
postFrame.closeBtn:Enable()
local undercut = (TSMAPI:GetCustomPriceValue(TSM.db.global.postUndercut, auctionRecord.itemString) or 1)
if undercut > auctionRecord.itemBuyout then
undercut = 1
end
if TSMAPI.Player:IsPlayer(auctionRecord.seller, true, true, true) then
-- don't undercut ourselves
undercut = 0
end
local auctionBuyout
if auctionRecord.isFake then
auctionBuyout = TSMAPI:GetCustomPriceValue(TSM.db.global.normalPostPrice, auctionRecord.itemString) or 1000000
else
auctionBuyout = auctionRecord.buyout - (undercut * auctionRecord.stackSize)
end
and I want to remove/replace this pattern
<tab here>if TSMAPI.Player:IsPlayer(auctionRecord.seller, true, true, true) then
<tab><tab>-- don't undercut ourselves
<tab><tab>undercut = 0
<tab here>end
via Powershell Script:
$text ="pattern_here!"
$content = [System.IO.File]::ReadAllText(path_to\test.lua")
(Get-Content 'path_to\test.lua') -replace $test,"example" | Set-Content 'path_to\test.lua'
So the script does replace/remove operations perfectly , but only in one string.
What I have already tried: use $text.contains with
`r `n `t `s — Escape characters
and even if PowerShell reply is "true" is doesn't change anything
this script from StackOverflow but it changes every string with "end", not only one which following next to "undercut = 0"
So, what am I join wrong? Already waste 3 H+ on this. Is it possible to use mask where first string should be start of $pattern and the first "end" will be the closing one?
Or I should covert all this strings to array? Or...use concat? Any ideas?