Hi,
Im having an issue with a regular expression im trying to figure out.
I need to get the last word at the end of an output from a cmd line tool, which I have made a PowerShell wrapper for.
Since I need to check if the output is “Enabled”, “Disabled”, “True”, “False”, “0” or “1”, I need to only get the last line/word from that output.
I am able to retrieve it using the following code:
$Request = & $AppPath -r $iDRACIp.IPAddressToString -u $Credential.GetNetworkCredential().UserName -p $Credential.GetNetworkCredential().Password "\""$Command\""" --nocertwarn# Get command output value $Output = Select-String -InputObject $Request -Pattern "[^=]+$" $Results = $Output.Matches.Value Return $Results</pre>
If I get the value "Disabled", the string length should be 8, but through testing it comes back as 10. Simply put, there are two hidden characters that I cant get rid of. Im not an expert in regular expressions, so any help is appreciate it.
Reference: https://regex101.com/r/bcvaZt/4
Thanks in advance