if (m/($regex)/) { print $regex; }
prints the pattern that matched the text in $1.
But why would you want that? It might be an XY Problem, and a better solution might exist.
In reply to Re: Regex: return the pattern instead of the actual match
by moritz
in thread Regex: return the pattern instead of the actual match
by Deus Ex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |