The goal is to get only the leading digits before a SPACE character from a string. When I use -replace
in PowerShell, leading alphabetic characters are included. Why is this different?
PS C:\src\t> 'aasdf123 456' -replace '([\d]+) .*', '$1'
aasdf123
This does not occur on regex101.com which produces.
123
Not a duplicate
The question is not how to get the number. The question is why does 'aasdf'
match \d
. The capture group specifies only \d
.