Build a replacement ball in regex.
In this challenge you will take a number $n$ and a string $X$ of length $\geq n$, and produce a regular expression which matches all strings that are withing $n$ character substitutions of $X$.
Specifically you will take $X$ and $n$ and ouptut all the ways to replace exactly $n$ characters with the regex wildcard
., separated by the regex or symbol
|. So for
bar and 2 as an input a valid output would be:
Order doesn't matter, but each replacement should appear exactly once, and no additional symbols should appear. Other regular expressions may perform the same task, but your output should meet the specifications above.
You can assume the input will consist only of the alphanumeric characters
This is code-golf, the goal is to minimize the size of your source code as measured in bytes.
o, 1 -> . at, 1 -> .t|a. moon, 1 -> .oon|m.on|mo.n|moo. at, 2 -> .. bar, 2 -> ..r|.a.|b.. test, 2 -> ..st|.e.t|.es.|t..t|t.s.|te.. case, 2 -> ..se|.a.e|.as.|c..e|c.s.|ca.. test, 3 -> ...t|..s.|.e..|t...
Ruby, 82 bytes ```ruby ->w …
Haskell + hgl, 30 bytes ``` …
Vyxal, 62 bitsv2, 8 bytes …