I can use backward reference in -Replace
operator in PowerShell. For example, this code
'abc456' -Replace '(abc)\d*', '$1def'
returns abcdef
. But I would like to use it not only with -Replace
operator but also with -Match
to check whether some string satisfies a regular expression.
Something like this
'aa' -Match '[a]$1'
But the code above returns false. Is it possible to use backward reference with -Match
operator?