I have the following PowerShell script:
$SCRIPTNAME = "myfile.js"
$SUBJECT = Get-Content $SCRIPTNAME | Out-String
if ($SUBJECT -match ".*/// COMMENT.*?$(.*)")
{
echo $matches[1];
}
$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
It is generating the following error (I'm trying to use regex capture groups, but its not working):
.* : The term '.*' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\User\Desktop\install.ps1:21 char:39
+ if ($SUBJECT -match ".*/// COMMENT.*?$(.*)")
+ ~~
+ CategoryInfo : ObjectNotFound: (.*:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Why is it having issues with the .*
part of the second capture group?