[regex]::match return a result, but not an index, on a VERY simple regex. Why?
With the relevant part of the variable:
$Details = "Requested Item
Number"
And the code:
$DetailStartPositionMatches = [regex]::match($Details,"Requested\ Item\s+Number")
write-host "`$DetailStartPositionMatches.success = `"$($DetailStartPositionMatches.success)`""
if($DetailStartPositionMatches.success)
{
write-host "`$match = `"$match`"" (have also tried $($match)
$DetailStartPosition = $match.index
}
else
{
write-host "no match"
}
write-host "`$DetailStartPosition = `"$DetailStartPosition`""
I get the output:
$DetailStartPositionMatches.success = "True"
$match = ""
$DetailStartPosition = ""
Of course...
$Details.indexof("Requested\ Item\s+Number")
...gives me the index fine.
What is wrong with the regex/data such I can't get the index from this code?