$s = "order #4271 shipped" # -match tests a regex and fills $matches if ($s -match '#(\d+)') { Write-Output "id is $($matches[1])" } # -replace substitutes with a regex Write-Output ($s -replace '\d+', 'XXXX')
regex test and substitution