Help with a... distant replacement?
-
So, I have lines like this:
"LOC_FN_StandardShield1Novice": "$[[LOC_FN_DankSorter_SpellTier1]]Protect", "LOC_FN_StandardShield2Apprentice": "$[[LOC_FN_DankSorter_SpellTier2]]Defend",
And I want to copy the initial LOC_FN string and use it to replace the name at the end of the lines, like this:
"LOC_FN_StandardShield1Novice": "$[[LOC_FN_DankSorter_SpellTier1]]$[["LOC_FN_StandardShield1Novice"]]", "LOC_FN_StandardShield2Apprentice": "$[[LOC_FN_DankSorter_SpellTier2]]$[["LOC_FN_StandardShield2Apprentice"]]",
I’ve looked through the documentation of RegEx a bit, and found that I can use
].*"
with Regular Expression checked to find all the names I want replaced, but I’m not experienced in this sort of thing and couldn’t quite wrap my head around how to tell it to replace that match with the string at the start of the line it’s on. Is there a way?
-
Wow, that is really non-trivial.
But I’d say to try starting with this regular expression replacement:Find:
(?-s)^(\t*"(.+?)": "\$\[{2}.+?\]{2}).+?,
Replace:${1}$[["${2}"]]",
-
@heyimaname-heyimalastname, @alan-kilborn and All,
Just a variant of the Alan’s search-replacement where the leading indentation and the
",
trailing string are NOT taken in account, in search :FIND
(?-s)(([^\h:\r\n]+).+?)\w+(?=",$)
REPLACE
\1$[[\2]]
For a similar result !
Best Regards,
guy038
-
@HeyImAName-HeyImALastName
This looks like JSON to me. While you may be able to achieve your desired result using regex alone, please be warned that JSON is meant to be parsed by a JSON parser, so you may find it easier to use a scripting language to parse the file before working with regular expressions. -
@Alan-Kilborn said in Help with a... distant replacement?:
Wow, that is really non-trivial.
But I’d say to try starting with this regular expression replacement:Find:
(?-s)^(\t*"(.+?)": "\$\[{2}.+?\]{2}).+?,
Replace:${1}$[["${2}"]]",
Wow, that looks like absolute gibberish to me, I can’t decipher it in the slightest. But I tried it and it worked perfectly! Thanks for your help, and everyone else who replied.