2016-11-16 58 views
1

我試圖用一個模板替換文件的某個部分,當我將其全部粘貼到替換字段並單擊替換時,該模板被截斷。記事本++替換函數字符數限制

我的搜索是:

\t// MODDED STUFF HERE.*// END MODDED STUFF 

我試圖來取代它:

\t// MODDED STUFF HERE\r\n\t\r\n\trmCreateTrigger\("MyTrigger"\+1\);\r\n\r\n\trmSwitchToTrigger\(rmTriggerID\("MyTrigger1"\)\);\r\n\tfor\(i=1; <rmGetNumberPlayersOnTeam\(0\)\+1\)\{\r\n\t\tfor\(j=0; <10\)\{\r\n\t\t\t// Titan Shield\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",452\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\t\r\n\t\t\t// Relic Eye of Horus\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",194\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\}\r\n\t\t\r\n\t\tfor\(j=0; <4\)\{\r\n\t\t\t// Acupuncture\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",562\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Temple of Healing\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",341\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\}\r\n\t\t\r\n\t\tfor\(j=0; <2\)\{\r\n\t\t\t// Thurisaz Rune\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",328\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Jade Rabbit\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",566\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Relic Head of Orpheus\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",196\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Relic Kithara of Apollo\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",201\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\t\r\n\t\t\t// Relic Pelt of Argus\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",369\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Relic Oseberg Wagon\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",370\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\}\r\n\t\t\r\n\t\t// Mythic Rejuvenation\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",432\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Heroic Renewal\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",433\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Hammer of the Gods\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",289\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Meteoric Iron Mail\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",290\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Dragonscale Shields\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",291\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Dwarven Mail\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",153\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Dwarven Weapons\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",155\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Relic Fetters of Fenrir\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",199\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\}\r\n\r\n\trmSetTriggerPriority\(3\);\r\n\trmSetTriggerActive\(true\);\r\n\trmSetTriggerRunImmediately\(true\);\r\n\trmSetTriggerLoop\(false\);\r\n\t\r\n\trmCreateTrigger\("MyTrigger"\+2\);\r\n\r\n\trmSwitchToTrigger\(rmTriggerID\("MyTrigger2"\)\);\r\n\t\r\n\trmAddTriggerCondition\("Timer"\);\r\n\trmSetTriggerConditionParamInt\("Param1",1\);\r\n\t\r\n\tfor\(i=1; <rmGetNumberPlayersOnTeam\(0\)\+1\)\{\r\n\t\trmAddTriggerEffect\("Grant Resources"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParam\("ResName","Food"\);\r\n\t\trmSetTriggerEffectParamInt\("Amount",2\);\r\n\t\t\r\n\t\trmAddTriggerEffect\("Grant Resources"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParam\("ResName","Wood"\);\r\n\t\trmSetTriggerEffectParamInt\("Amount",2\);\r\n\t\t\r\n\t\trmAddTriggerEffect\("Grant Resources"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParam\("ResName","Gold"\);\r\n\t\trmSetTriggerEffectParamInt\("Amount",2\);\r\n\t\}\r\n\t\r\n\trmSetTriggerPriority\(3\);\r\n\trmSetTriggerActive\(true\);\r\n\trmSetTriggerRunImmediately\(false\);\r\n\trmSetTriggerLoop\(true\);\r\n\t\r\n\t// END MODDED STUFF 

但是那部分被切斷。我希望能夠使用替換函數替換它而不是直接複製和粘貼它的原因是因爲我需要對多個文件(超過30個)進行完全相同的替換,所以通過使用替換函數可以更有效查找和替換功能,而不是每次都複製和粘貼。

有沒有辦法做到這一點,沒有部分更換文字被我假設的字符限制截斷?或者,如果有另一種方式來做我不需要的淫穢複雜的東西,我願意接受建議。

回答

0

正如您所指出的,使用Notepad ++和TextWrangler等軟件在可替換字段內可以粘貼的字符數量方面受到限制。

如果您想進行這種替換,您將不得不使用Python,PHP等編程語言。

例如,你可以在PHP中使用此代碼做到這一點:上述

<?php 
    $replace_text = $_POST['replace']; 
    $target_text = ' \r\n\t\r\n\trmCreateTrigger\("MyTrigger"\+1\);\r\n\r\n\trmSwitchToTrigger\(rmTriggerID\("MyTrigger1"\)\);\r\n\tfor\(i=1; &lt;rmGetNumberPlayersOnTeam\(0\)\+1\)\{\r\n\t\tfor\(j=0; <10\)\{\r\n\t\t\t// Titan Shield\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",452\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\t\r\n\t\t\t// Relic Eye of Horus\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",194\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\}\r\n\t\t\r\n\t\tfor\(j=0; <4\)\{\r\n\t\t\t// Acupuncture\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",562\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Temple of Healing\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",341\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\}\r\n\t\t\r\n\t\tfor\(j=0; <2\)\{\r\n\t\t\t// Thurisaz Rune\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",328\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Jade Rabbit\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",566\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Relic Head of Orpheus\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",196\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Relic Kithara of Apollo\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",201\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\t\r\n\t\t\t// Relic Pelt of Argus\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",369\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t\t// Relic Oseberg Wagon\r\n\t\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\t\trmSetTriggerEffectParamInt\("TechID",370\);\r\n\t\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\}\r\n\t\t\r\n\t\t// Mythic Rejuvenation\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",432\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Heroic Renewal\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",433\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Hammer of the Gods\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",289\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Meteoric Iron Mail\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",290\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Dragonscale Shields\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",291\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Dwarven Mail\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",153\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Dwarven Weapons\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",155\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\t\r\n\t\t// Relic Fetters of Fenrir\r\n\t\trmAddTriggerEffect\("Set Tech Status"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParamInt\("TechID",199\);\r\n\t\trmSetTriggerEffectParamInt\("Status",4\);\r\n\t\}\r\n\r\n\trmSetTriggerPriority\(3\);\r\n\trmSetTriggerActive\(true\);\r\n\trmSetTriggerRunImmediately\(true\);\r\n\trmSetTriggerLoop\(false\);\r\n\t\r\n\trmCreateTrigger\("MyTrigger"\+2\);\r\n\r\n\trmSwitchToTrigger\(rmTriggerID\("MyTrigger2"\)\);\r\n\t\r\n\trmAddTriggerCondition\("Timer"\);\r\n\trmSetTriggerConditionParamInt\("Param1",1\);\r\n\t\r\n\tfor\(i=1; &lt;rmGetNumberPlayersOnTeam\(0\)\+1\)\{\r\n\t\trmAddTriggerEffect\("Grant Resources"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParam\("ResName","Food"\);\r\n\t\trmSetTriggerEffectParamInt\("Amount",2\);\r\n\t\t\r\n\t\trmAddTriggerEffect\("Grant Resources"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParam\("ResName","Wood"\);\r\n\t\trmSetTriggerEffectParamInt\("Amount",2\);\r\n\t\t\r\n\t\trmAddTriggerEffect\("Grant Resources"\);\r\n\t\trmSetTriggerEffectParamInt\("PlayerID",i\);\r\n\t\trmSetTriggerEffectParam\("ResName","Gold"\);\r\n\t\trmSetTriggerEffectParamInt\("Amount",2\);\r\n\t\}\r\n\t\r\n\trmSetTriggerPriority\(3\);\r\n\trmSetTriggerActive\(true\);\r\n\trmSetTriggerRunImmediately\(false\);\r\n\trmSetTriggerLoop\(true\);\r\n\t\r\n\t '; 
    $replace_text = preg_replace("/(?<=HERE)(\.\*)/", $target_text , $replace_text); 
    echo $replace_text; 
?> 

保存PHP代碼,並將其命名爲a.php

添加其他文件,使PHP工作,該文件將成爲HTML和下面的代碼複製裏面,並將其保存爲a.html

<form action="b.php" method="POST"> 
 
Text: <input style="width: 500px; height: 80px; margin:5px; padding: 5px;" type="text" name="replace"> 
 
    <br /><br /> 
 
<input value="replace" style="margin:5px; width: 100px; height: 40px;" type="submit"> 
 
</form>

現在,運行一個。在任何本地主機的HTML文件,它應該工作!

這是我使用的正則表達式,如果需要,可以從PHP文件'a.php'更改它以適合您的需要。

(?<=HERE)(\.\*)