Skip to content

Find & Multi replace

antD97 edited this page May 18, 2022 · 1 revision

Repeat a line while replacing part of it with values from a list.

Format:

#!find=<pattern>
#!replace=<replace|...>
<command>

For every string in <replace|...> that is separated by |s, a new line will replace the following line <command> while replacing all occurrences of <find> in the line with each string in <replace|...>.

Find regex: ^\s*#!find=(.*)$
Replace regex: ^\s*#!replace=(.*)$

This:

#!find=creeper
#!replace=creeper|skeleton|zombie
execute as @e[type=creeper] run say I'm a creeper!

Turns into this:

execute as @e[type=creeper] run say I'm a creeper!
execute as @e[type=skeleton] run say I'm a skeleton!
execute as @e[type=zombie] run say I'm a zombie!
Clone this wiki locally