Let's say I have this string:
"14 be h90 bfh4"
And I have this regex pattern:
"(\w+)\d"
In PowerShell, how do I get an array with the contents {"h", "bfh"}?
You want to capture one or more alphabets that are followed by a number, hence the regex for what you want to capture would be this,
[a-zA-Z]+(?=\d)
And the powershell code for same will be this,
$str = "14 be h90 bfh4"
$reg = "[a-zA-Z]+(?=\d)"
$spuntext = $str | Select-String $reg -AllMatches |
ForEach-Object { $_.Matches.Value }
echo $spuntext
Disclaimer: I barely know powershell scripting language so you may have to tweak some codes.
$array = ($string -split '(\s)') -replace '[^a-zA-Z-]','' | SELECT-STRING -Pattern '([A-Z])'$result = Select-String '\b(\p{L}+)\d+\b' -Input "14 be h90 bfh4" -AllMatches|%{$_.Matches.Groups[1].Value}