Basically, I need to match with 1 per line but right now, my regex is matching 2 per line.
https://regex101.com/r/KmgGwS/8
My regex is looking for 2 slashes and it returns the string in between but the problem is my path has multiple slashes and I only need to match it with the 2nd match per each line
(?<=\\).*?(?=\\)
This is my PowerShell code:
if ( $_.PSPath -match ("(?<=::).*?(?=\\)")) {
$user = $matches.Values
}
For example:
Microsoft.PowerShell.Security\Certificate::CurrentUser\Root\CDD4EEAE6000AC7F40C3802C171E30148030C072 Microsoft.PowerShell.Security\Certificate::CurrentUser\Root\BE36A4562FB2EE05DBB3D32323ADF445084ED656
What my code does is it gets
Certificate::CurrentUserRoot Certificate::CurrentUserRoot
but what I only really need is get the string to the 2nd match \ ___\ which is:
Root Root