@Clyde-Parker said in Replace text inside double quotes:
Thanks for your help, i was actually looking for the regex to replace text inside quotes but i can’t do every single word working with huge files
Yeah, you’re still not giving us enough to go on. The regex ".*?" will match text inside a quote, or ^".*?" will match only text inside a quote that begins a line, or (?<^").*?(?=") will match the text inside the quotes at the start of a line, without matching the quote marks themselves. But there is no easy way to make a map of word->replacement in the REPLACE portion of the regex.
if you’ve got a list of 5-10 words that you HAVE, and the associated words that you WANT to convert them to, then it’s not too difficult to produce a regex that will do it. But if you’ve got hundreds or thousands of words that you want to map from one to another, you won’t be able to do it in a single manual regex.
That said, our resident regex gurus have some tricks up their sleeves. So if you said you were able to put the list of HAVE => WANT words at the end of the file, and weren’t picky about the format for that list, someone might be able to chime in with a way to get that to miraculously transform it.
Personally, while I find such solutions academically interesting the first time I see them, they have their limitations (if the main text file gets too long, the magic regex cannot extend all the way from the real text to the mapping at the bottom).
Really, if I were doing this, once it got to this stage of a huge list of replacement maps, I would just write a command-line script to do it in my favorite programming language; but that’s off-topic here.
But if I were going to solve this “inside” Notepad++, I would pull out a plugin like PythonScript: open the text to be edited in the “main” editor view and a separate file that would have the HAVE => WANT pairs in some easy-to-parse format (like HAVE => WANT or HAVE,WANT or HAVE [tab] WANT) and write some python code which would process the mapping file view line-by-line, then run the search-and-replace on the main editor view, and loop through all the changes you want to make. I’m actually pretty sure someone has shown such code in the forum before – maybe even me. But searching the forum for “PythonScript map” or some such will produce a lot of results that you’d have to wade through to find – and you might have to try variations, because everyone phrases it differently.
Again, I highly recommend reading the advice I gave above, and trying to add enough information that someone could meaningfully give a detailed solution, rather than just my high-level “if you’re lucky, it might be doable with fancy regex, but we cannot know until you give us more detail; or it could also be done through scripting, but how exactly that will look might depend on what your data is really like, and what format your list of replacements is in”.