- or download this
$regex = join ...
$regex = qr/...
- or download this
$regex_base_str = join ...
$regex_compiled = qr/...
- or download this
# Simple case: OK - matches "a" or "b"
$ perl -E 'my $re = "a|b"; $re = qr{$re}; say $re'
...
# Complex case: OK - matches "a" or "b" [fixed with "(?:...)"]
$ perl -E 'my $re = "(?:a|b)"; $re = qr{X${re}Y}; say $re'
(?^u:X(?:a|b)Y)