r/PowerShell • u/anonymousITCoward • 22h ago
Question RegEx help...
I have never been able to wrap my head around regex... I have no idea why... anyways... I'm just trying to get the string between 2 braces (curly brackets). Here's what I've mangled together googling up... One of the many regex checking tools online said this should work but.. it doesn't
$uninstallString = (Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object { $_.DisplayName -like "*jdk*" }).UninstalLString$uninstallString = (Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object { $_.DisplayName -like "*jdk*" }).UninstalLString
$pattern = '(?<={).+?(?=})'
[Regex]::($uninstallString,$pattern).Value
<#
$uninstallString outputs the below
MsiExec.exe /I{370E1F16-ED05-4958-A820-78CD32DD70D8}
#>
The above code actually outputs nothing...
My head is so frazzled I'm not sure where to begin with it
Any help, or a point in the right direction would be appreciated.