Magic mirror madness Introduction

I have a room full of magic mirrors.
They are mysterious artifacts that can duplicate any item, except another magic mirror.
More explicitly, a duplicate version of the item will appear on the other side of the mirror, at the same distance.
However, if there is another magic mirror in the way on either side, between the duplicating mirror and either item (original or duplicate), the duplicate is not formed.
The original item can be either left or right of the mirror, and the duplicate will appear on the other side.
Also, the duplicate item can itself be duplicated by another mirror.
Items never block the duplication of other items (except by being directly on the position of the would-be duplicate).

Input

Your input is a string consisting of the characters .#|, which represent empty space, items, and magic mirrors.
There will always be at least one magic mirror in the input.

Output

Your output shall be another string where each magic mirror has duplicated every item it can, according to the rules above.
You can assume that there will always be an empty space on the spot where a duplicate item appears (so they will no go out of bounds).

Examples

Consider the input string

.#.|.....|......#
 A B     C      D


where we have marked some positions for clarity.
The mirror B duplicates item A, which ends up to its right:

.#.|.#...|......#
 A B     C      D


Mirror C then duplicates the new item:

.#.|.#...|...#..#
 A B     C      D


Mirror C cannot duplicate item A, since mirror B is in the way.
It also cannot duplicate item D, since mirror B is in the way on the other side.
Likewise, mirror B cannot duplicate item D or the duplicate next to it, since mirror C is in the way, so this is the correct output.

For another example, consider the input

.##..#...|#..##...|..##....#.
 AB  C   DE  FG   H  IJ    K


Mirror D can duplicate A and B to the right, and E and G to the left.
C and F are already duplicates of each other.
The string becomes

.##.##..#|#..##.##|..##....#.
 AB  C   DE  FG   H  IJ    K


Mirror H can duplicate E, F, and the duplicates of A and B to the right, and I to the left.
G and J are already duplicates of each other, and mirror D is in the way of K.
Now we have

.##.##..#|#..#####|#####..##.
 AB  C   DE  FG   H  IJ    K


Finally, mirror D can duplicate the duplicate of I to the left.
We end up with

.#####..#|#..#####|#####..##.
 AB  C   DE  FG   H  IJ    K


Rules and scoring

You can write either a full program or a function.
The lowest byte count wins.
Submissions that don't use regex engines compete separately from those that do, and may be marked with (no regex).

Test cases

"|" -&gt; "|"
"..|.." -&gt; "..|.."
".#.|..." -&gt; ".#.|.#."
"..#|.#." -&gt; ".##|##."
".#..|....|.." -&gt; ".#..|..#.|.#"
".|..|.#....." -&gt; "#|#.|.#....."
"...|.#...|....#" -&gt; ".##|##...|...##"
"......#|......." -&gt; "......#|#......"
".#.|.....|......#" -&gt; ".#.|.#...|...#..#"
".......|...#.##|...." -&gt; "##.#...|...#.##|##.#"
"...#..||.......#..#...#" -&gt; "...#..||.......#..#...#"
".##|.#....||#||......#|.#" -&gt; ".##|##....||#||.....##|##"
".##..#...|#..##...|..##....#." -&gt; ".#####..#|#..#####|#####..##."
".#|...||...|#...|..##...|#...." -&gt; ".#|#..||.##|##..|..##..#|#..##"
"....#.|...#.|..|.|.....|..#......" -&gt; "..#.#.|.#.#.|.#|#|#.#..|..#.#...."
"..|....|.....#.|.....|...|.#.|..|.|...#......" -&gt; ".#|#...|...#.#.|.#.#.|.#.|.#.|.#|#|#..#......"
Retina, 50 bytes

+`([#.])(([#.])*\|(?&gt;(?&lt;-3&gt;[#.])*))(?!\1)[#.]
#$2#


Try it online! (The first line enables a linefeed-separated test suite.)

I guess this is the opposite of a (no regex) submission.

Explanation

This is simply a regex substitution, which is applied repeatedly (+) until the string stops changing. I'm using balancing groups to make sure that the two mirrored positions are the same distance from the given mirror (backreferences won't do, since the exact string on both sides of the | may be different).

([#.])            # Match and capture a non-mirror cell.
(                 # This will match and capture everything up to its corresponding
                  # cell so that we can write it back in the substitution.
  ([#.])*         #   Match zero or more non-mirror cells and push each one onto
                  #   group 3. This counts the distance from our first match to
                  #   the mirror.
  \|              #   Match the mirror.
  (?&gt;             #   Atomic group to prevent backtracking.
    (?&lt;-3&gt;[#.])*  #     Match non-mirror while popping from group 3.
  )               #   There are three reasons why the previous repetition
                  #   might stop:
                  #   - Group 3 was exhausted. That's good, the next position
                  #     corresponds to the first character we matched.
                  #   - We've reached the end of the string. That's fine,
                  #     the last part of the regex will cause the match to fail.
                  #   - We've hit another mirror. That's also fine, because
                  #     the last part of the regex will still fail.
)
(?!\1)            # Make sure that the next character isn't the same as the first
                  # one. We're looking for .|# or #|., not for #|# or .|.
[#.]              # Match the last non-mirror character.


This is replaced with #$2# which simply replaces both the first and last character of the match with a #.