The regex gurus on this forum might come up with some kind of crazy regex-based solution to this, but this is pretty easy to solve with PythonScript.
# requires PythonScript: https://github.com/bruderstein/PythonScript/releases
# ref: https://community.notepad-plus-plus.org/topic/25388/replace-guid-with-guid-from-list-randomly
import random
import re
from Npp import editor, notepad, MESSAGEBOXFLAGS
def main():
thing_to_replace = notepad.prompt('Enter the text you want to replace',
'enter text to replace', '')
if not thing_to_replace:
return
is_regex = notepad.messageBox(
'Is the thing you want to replace a regular expression?',
'regular expression?',
MESSAGEBOXFLAGS.YESNO) == MESSAGEBOXFLAGS.RESULTYES
if not is_regex:
thing_to_replace = '(?-s)' + re.escape(thing_to_replace)
replacements = notepad.prompt(
'Enter a list of replacements (one per line)',
'list of replacements', '')
if not replacements:
return
replacement_list = replacements.strip().splitlines()
def get_random_from_list(_):
return random.choice(replacement_list)
editor.rereplace(thing_to_replace, get_random_from_list)
if __name__ == '__main__':
main()