我有一个包含 500 多行文本的文本文件。每行都会有一个以 开头的部分<p><strong>Spell Lists.</strong>
,然后是“类”列表(例如Artificer, Bard, Wizard
或 )Druid, Ranger
,最后以 结尾</p>
。
我的目标是用我为我的程序使用的特殊链接替换每个类。该链接将类似于@UUID[uniqueID]{className}
。
通常我会在 Notepad++ 中对每个类名使用“查找和替换”,但类名出现在文档的其他部分,我不想删除这些类名,所以我需要替换上面列出的上下文中的类名。我确信我可以使用 RegEx 来做到这一点,但我以前从未使用过它,所以我不知道如何正确地做到这一点。任何帮助都将不胜感激。谢谢!
输入示例:
{"name":"Pyrotechnics","type":"spell","img":"icons/magic/fire/beam-jet-stream-embers.webp","effects":[],"folder":null,"sort":0,"flags":{"betterRolls5e":{"critRange":{"type":"String","value":null},"critDamage":{"type":"String","value":""},"quickDesc":{"type":"Boolean","value":true,"altValue":true},"quickAttack":{"type":"Boolean","value":true,"altValue":true},"quickSave":{"type":"Boolean","value":true,"altValue":true},"quickDamage":{"type":"Array","value":[],"altValue":[],"context":[]},"quickVersatile":{"type":"Boolean","value":false,"altValue":false},"quickProperties":{"type":"Boolean","value":true,"altValue":true},"quickCharges":{"type":"Boolean","value":{"use":true,"resource":true},"altValue":{"use":true,"resource":true}},"quickTemplate":{"type":"Boolean","value":true,"altValue":true},"quickOther":{"type":"Boolean","value":true,"altValue":true,"context":""},"quickFlavor":{"type":"Boolean","value":true,"altValue":true},"quickPrompt":{"type":"Boolean","value":false,"altValue":false}},"core":{"sourceId":"Item.yrc5woADzAc984yq"}},"_id":"0BSwV45mHGYEPMru","system":{"description":{"value":"<p>Choose an area of flame that you can see and that can fit within a 5-foot cube within range. You can extinguish the fire in that area, and you create either fireworks or smoke.</p><p><strong>Fireworks.</strong> The target explodes with a dazzling display of colors. Each creature within 10 feet of the target must succeed on a Constitution saving throw or become blinded until the end of your next turn.</p><p><strong>Smoke.</strong> Thick black smoke spreads out from the target in a 20-foot radius, moving around corners. The area of the smoke is heavily obscured. The smoke persists for 1 minute or until a strong wind disperses it.</p><p><strong>Spell Lists.</strong> Sorcerer, Wizard, Artificer</p>","chat":"","unidentified":""},"source":"XGE","activation":{"type":"action","cost":1,"condition":""},"duration":{"value":null,"units":"inst"},"target":{"value":5,"width":null,"units":"ft","type":"cube"},"range":{"value":60,"long":null,"units":"ft"},"uses":{"value":0,"max":"0","per":"","recovery":""},"consume":{"type":"","target":"","amount":null},"ability":"","actionType":"save","attackBonus":0,"chatFlavor":"","critical":{"threshold":null,"damage":null},"damage":{"parts":[],"versatile":""},"formula":"","save":{"ability":"con","dc":null,"scaling":"spell"},"level":2,"school":"trs","components":{"value":"","vocal":true,"somatic":true,"material":false,"ritual":false,"concentration":false},"materials":{"value":"","consumed":false,"cost":0,"supply":0},"preparation":{"mode":"prepared","prepared":false},"scaling":{"mode":"none","formula":""}},"ownership":{"default":0,"LCw1mxC8S2Al3dWA":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.286","createdTime":null,"modifiedTime":1664781982673,"lastModifiedBy":"UjfixXuqstXNdypa"}}
{"_id":"0QjwfM5ugpGCZIDV","name":"Resistance","type":"spell","img":"icons/magic/defensive/shield-barrier-blue.webp","effects":[],"folder":null,"sort":0,"flags":{"core":{"sourceId":"Compendium.world.spells-expanded.dl8YwvMboBqX2OC4"},"mre-dnd5e":{"formulaGroups":[{"label":"Primary","formulaSet":[]}]},"rest-recovery":{"data":{"recovery":{"enabled":false}}}},"system":{"description":{"value":"<p>You touch one willing creature. Once before the spell ends, the target can roll a d4 and add the number rolled to one saving throw of its choice. It can roll the die before or after making the saving throw. The spell then ends.</p><p><strong>Spell Lists.</strong>Cleric, Druid</p>","chat":"","unidentified":""},"source":"PHB","activation":{"type":"action","cost":1,"condition":""},"duration":{"value":1,"units":"minute"},"target":{"value":1,"width":null,"units":"","type":"creature"},"range":{"value":null,"long":null,"units":"touch"},"uses":{"value":0,"max":"0","per":"","recovery":""},"consume":{"type":"","target":"","amount":null},"ability":"","actionType":"util","attackBonus":0,"chatFlavor":"","critical":{"threshold":null,"damage":null},"damage":{"parts":[],"versatile":"","value":""},"formula":"1d4","save":{"ability":"","dc":null,"scaling":"spell","value":""},"level":0,"school":"abj","components":{"value":"","vocal":true,"somatic":true,"material":true,"ritual":false,"concentration":true},"materials":{"value":"A miniature clock","consumed":false,"cost":0,"supply":0},"preparation":{"mode":"prepared","prepared":false},"scaling":{"mode":"none","formula":""}},"ownership":{"default":0,"LCw1mxC8S2Al3dWA":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.288","createdTime":null,"modifiedTime":1668307772539,"lastModifiedBy":"EHpONhziSoZpUpN3"}}
{"_id":"0WqAKsgwfM272Ugk","name":"Elemental Bane","type":"spell","img":"icons/skills/melee/shield-damaged-broken-gold.webp","effects":[],"folder":null,"sort":0,"flags":{"betterRolls5e":{"critRange":{"type":"String","value":null},"critDamage":{"type":"String","value":""},"quickDesc":{"type":"Boolean","value":true,"altValue":true},"quickAttack":{"type":"Boolean","value":true,"altValue":true},"quickSave":{"type":"Boolean","value":true,"altValue":true},"quickDamage":{"type":"Array","value":[],"altValue":[],"context":[]},"quickVersatile":{"type":"Boolean","value":false,"altValue":false},"quickProperties":{"type":"Boolean","value":true,"altValue":true},"quickCharges":{"type":"Boolean","value":{"use":true,"resource":true},"altValue":{"use":true,"resource":true}},"quickTemplate":{"type":"Boolean","value":true,"altValue":true},"quickOther":{"type":"Boolean","value":true,"altValue":true,"context":""},"quickFlavor":{"type":"Boolean","value":true,"altValue":true},"quickPrompt":{"type":"Boolean","value":false,"altValue":false}},"core":{"sourceId":"Item.VsKT5bvnBuMZpsqp"},"mre-dnd5e":{"formulaGroups":[{"label":"Primary","formulaSet":[]}]}},"system":{"description":{"value":"<p>Choose one creature you can see within range, and choose one of the following damage types: acid, cold, fire, lightning, or thunder. The target must succeed on a Constitution saving throw or be affected by the spell for its duration. The first time each turn the affected target takes damage of the chosen type, the target takes an extra 2d6 damage of that type. Moreover, the target loses any resistance to that damage type until the spell ends.</p>\n<p><strong>At Higher Levels.</strong> When you cast this spell using a spell slot of 5th level or higher, you can target one additional creature for each slot level above 4th. The creatures must be within 30 feet of each other when you target them.</p>\n<p><strong>Spell Lists.</strong> Warlock, Wizard, Artificer</p>","chat":"","unidentified":""},"source":"XGE","activation":{"type":"action","cost":1,"condition":""},"duration":{"value":1,"units":"minute"},"target":{"value":1,"width":null,"units":"","type":"creature"},"range":{"value":90,"long":null,"units":"ft"},"uses":{"value":0,"max":"0","per":"","recovery":""},"consume":{"type":"","target":"","amount":null},"ability":"","actionType":"save","attackBonus":0,"chatFlavor":"","critical":{"threshold":null,"damage":null},"damage":{"parts":[],"versatile":""},"formula":"","save":{"ability":"con","dc":null,"scaling":"spell"},"level":4,"school":"trs","components":{"value":"","vocal":true,"somatic":true,"material":false,"ritual":false,"concentration":true},"materials":{"value":"","consumed":false,"cost":0,"supply":0},"preparation":{"mode":"prepared","prepared":false},"scaling":{"mode":"none","formula":""}},"ownership":{"default":0,"LCw1mxC8S2Al3dWA":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.286","createdTime":null,"modifiedTime":1664757812337,"lastModifiedBy":"WaZ5phMRyaHwTSEz"}}
期望输出:
{"name":"Pyrotechnics","type":"spell","img":"icons/magic/fire/beam-jet-stream-embers.webp","effects":[],"folder":null,"sort":0,"flags":{"betterRolls5e":{"critRange":{"type":"String","value":null},"critDamage":{"type":"String","value":""},"quickDesc":{"type":"Boolean","value":true,"altValue":true},"quickAttack":{"type":"Boolean","value":true,"altValue":true},"quickSave":{"type":"Boolean","value":true,"altValue":true},"quickDamage":{"type":"Array","value":[],"altValue":[],"context":[]},"quickVersatile":{"type":"Boolean","value":false,"altValue":false},"quickProperties":{"type":"Boolean","value":true,"altValue":true},"quickCharges":{"type":"Boolean","value":{"use":true,"resource":true},"altValue":{"use":true,"resource":true}},"quickTemplate":{"type":"Boolean","value":true,"altValue":true},"quickOther":{"type":"Boolean","value":true,"altValue":true,"context":""},"quickFlavor":{"type":"Boolean","value":true,"altValue":true},"quickPrompt":{"type":"Boolean","value":false,"altValue":false}},"core":{"sourceId":"Item.yrc5woADzAc984yq"}},"_id":"0BSwV45mHGYEPMru","system":{"description":{"value":"<p>Choose an area of flame that you can see and that can fit within a 5-foot cube within range. You can extinguish the fire in that area, and you create either fireworks or smoke.</p><p><strong>Fireworks.</strong> The target explodes with a dazzling display of colors. Each creature within 10 feet of the target must succeed on a Constitution saving throw or become blinded until the end of your next turn.</p><p><strong>Smoke.</strong> Thick black smoke spreads out from the target in a 20-foot radius, moving around corners. The area of the smoke is heavily obscured. The smoke persists for 1 minute or until a strong wind disperses it.</p><p><strong>Spell Lists.</strong>@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.NX28XQnco4pjOzF6]{Sorcerer}@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.5YX3k6END6NQWHOB]{Wizard}@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.3wFSjqwXndAQ8P2i]{Artificer}</p>","chat":"","unidentified":""},"source":"XGE","activation":{"type":"action","cost":1,"condition":""},"duration":{"value":null,"units":"inst"},"target":{"value":5,"width":null,"units":"ft","type":"cube"},"range":{"value":60,"long":null,"units":"ft"},"uses":{"value":0,"max":"0","per":"","recovery":""},"consume":{"type":"","target":"","amount":null},"ability":"","actionType":"save","attackBonus":0,"chatFlavor":"","critical":{"threshold":null,"damage":null},"damage":{"parts":[],"versatile":""},"formula":"","save":{"ability":"con","dc":null,"scaling":"spell"},"level":2,"school":"trs","components":{"value":"","vocal":true,"somatic":true,"material":false,"ritual":false,"concentration":false},"materials":{"value":"","consumed":false,"cost":0,"supply":0},"preparation":{"mode":"prepared","prepared":false},"scaling":{"mode":"none","formula":""}},"ownership":{"default":0,"LCw1mxC8S2Al3dWA":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.286","createdTime":null,"modifiedTime":1664781982673,"lastModifiedBy":"UjfixXuqstXNdypa"}}
{"_id":"0QjwfM5ugpGCZIDV","name":"Resistance","type":"spell","img":"icons/magic/defensive/shield-barrier-blue.webp","effects":[],"folder":null,"sort":0,"flags":{"core":{"sourceId":"Compendium.world.spells-expanded.dl8YwvMboBqX2OC4"},"mre-dnd5e":{"formulaGroups":[{"label":"Primary","formulaSet":[]}]},"rest-recovery":{"data":{"recovery":{"enabled":false}}}},"system":{"description":{"value":"<p>You touch one willing creature. Once before the spell ends, the target can roll a d4 and add the number rolled to one saving throw of its choice. It can roll the die before or after making the saving throw. The spell then ends.</p><p><strong>Spell Lists.</strong>@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.G7cm1ctzhtxEOvxS]{Cleric}@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.1IHQ3bZ4aCi15dlH]{Druid}</p>","chat":"","unidentified":""},"source":"PHB","activation":{"type":"action","cost":1,"condition":""},"duration":{"value":1,"units":"minute"},"target":{"value":1,"width":null,"units":"","type":"creature"},"range":{"value":null,"long":null,"units":"touch"},"uses":{"value":0,"max":"0","per":"","recovery":""},"consume":{"type":"","target":"","amount":null},"ability":"","actionType":"util","attackBonus":0,"chatFlavor":"","critical":{"threshold":null,"damage":null},"damage":{"parts":[],"versatile":"","value":""},"formula":"1d4","save":{"ability":"","dc":null,"scaling":"spell","value":""},"level":0,"school":"abj","components":{"value":"","vocal":true,"somatic":true,"material":true,"ritual":false,"concentration":true},"materials":{"value":"A miniature clock","consumed":false,"cost":0,"supply":0},"preparation":{"mode":"prepared","prepared":false},"scaling":{"mode":"none","formula":""}},"ownership":{"default":0,"LCw1mxC8S2Al3dWA":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.288","createdTime":null,"modifiedTime":1668307772539,"lastModifiedBy":"EHpONhziSoZpUpN3"}}
{"_id":"0WqAKsgwfM272Ugk","name":"Elemental Bane","type":"spell","img":"icons/skills/melee/shield-damaged-broken-gold.webp","effects":[],"folder":null,"sort":0,"flags":{"betterRolls5e":{"critRange":{"type":"String","value":null},"critDamage":{"type":"String","value":""},"quickDesc":{"type":"Boolean","value":true,"altValue":true},"quickAttack":{"type":"Boolean","value":true,"altValue":true},"quickSave":{"type":"Boolean","value":true,"altValue":true},"quickDamage":{"type":"Array","value":[],"altValue":[],"context":[]},"quickVersatile":{"type":"Boolean","value":false,"altValue":false},"quickProperties":{"type":"Boolean","value":true,"altValue":true},"quickCharges":{"type":"Boolean","value":{"use":true,"resource":true},"altValue":{"use":true,"resource":true}},"quickTemplate":{"type":"Boolean","value":true,"altValue":true},"quickOther":{"type":"Boolean","value":true,"altValue":true,"context":""},"quickFlavor":{"type":"Boolean","value":true,"altValue":true},"quickPrompt":{"type":"Boolean","value":false,"altValue":false}},"core":{"sourceId":"Item.VsKT5bvnBuMZpsqp"},"mre-dnd5e":{"formulaGroups":[{"label":"Primary","formulaSet":[]}]}},"system":{"description":{"value":"<p>Choose one creature you can see within range, and choose one of the following damage types: acid, cold, fire, lightning, or thunder. The target must succeed on a Constitution saving throw or be affected by the spell for its duration. The first time each turn the affected target takes damage of the chosen type, the target takes an extra 2d6 damage of that type. Moreover, the target loses any resistance to that damage type until the spell ends.</p>\n<p><strong>At Higher Levels.</strong> When you cast this spell using a spell slot of 5th level or higher, you can target one additional creature for each slot level above 4th. The creatures must be within 30 feet of each other when you target them.</p>\n<p><strong>Spell Lists.</strong>@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.JsbrmCx9VF1Sizn8]{Warlock}@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.5YX3k6END6NQWHOB]{Wizard}@UUID[Compendium.5e-complete.5e-journals.7iH4qANs2gxn0MIs.JournalEntryPage.3wFSjqwXndAQ8P2i]{Artificer}</p>","chat":"","unidentified":""},"source":"XGE","activation":{"type":"action","cost":1,"condition":""},"duration":{"value":1,"units":"minute"},"target":{"value":1,"width":null,"units":"","type":"creature"},"range":{"value":90,"long":null,"units":"ft"},"uses":{"value":0,"max":"0","per":"","recovery":""},"consume":{"type":"","target":"","amount":null},"ability":"","actionType":"save","attackBonus":0,"chatFlavor":"","critical":{"threshold":null,"damage":null},"damage":{"parts":[],"versatile":""},"formula":"","save":{"ability":"con","dc":null,"scaling":"spell"},"level":4,"school":"trs","components":{"value":"","vocal":true,"somatic":true,"material":false,"ritual":false,"concentration":true},"materials":{"value":"","consumed":false,"cost":0,"supply":0},"preparation":{"mode":"prepared","prepared":false},"scaling":{"mode":"none","formula":""}},"ownership":{"default":0,"LCw1mxC8S2Al3dWA":3},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.286","createdTime":null,"modifiedTime":1664757812337,"lastModifiedBy":"WaZ5phMRyaHwTSEz"}}