8,330 questions
In a regex the escape character is "\", not "/".
$test = 'write-host "bogus!" [int]$license Some Other stuff'
$test -match '\[int\]\$license'
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to find all occurrences of following pattern [int]$license in a script located on multiple machines. When I run $test | select-string -pattern '/[int/]' where $test holds the content of the file, this works as long as I won't add the dollar sign afterwards. I tried '/[int/]/$license' and '/[int/]`$license' but neither works which proves my regex is useless :) Can someone help with this?
In a regex the escape character is "\", not "/".
$test = 'write-host "bogus!" [int]$license Some Other stuff'
$test -match '\[int\]\$license'
Try this $test | select-string -pattern '\[int\]\$license'
Indeed. Silly as it is it was the wrong character I was trying to use.