I'm not very good at regex with powershell and could use some help. The reason I'm using regex here is to accomidate for whitespaces (and any other text I can't think of atm that is not expected), so then the junk is stripped away to get the value that is wanted.
I'm trying the following code...
[String[]]$listOfStrings = @(' token = true ', ' token = false ', ' token = True ', ' token = False ')
For ($stringNumber = 0; $stringNumber -lt $listOfStrings.length; $stringNumber++)
{
[String]$stringTest = ($listOfStrings[$stringNumber] -replace '*token*=','').Trim()
Write-Host $stringTest
}
The output should be the following...
true
false
True
False
However, I'm getting the following error message...
Invalid regular expression pattern: *token*=.
At :line:5 char:63
+ [String]$stringTest = ($listOfStrings[$stringNumber] -replace <<<< '*token*=','').Trim()
Any help is much appreciated.