So, here the example below.
Application Details for the XYZ application:
=========================================================
Application Name: XYXZW1
Application Id: XYZ353WERX
Application Details for the XYZ application:
=========================================================
Application Name: XYXZW2
Application Id: XYZ353WERX
Application Details for the XYZ application:
=========================================================
Application Name: XYXZW3
Application Id: XYZ353WERX
Secret Key: XYZ86JBHHSD
Application Details for the XYZ application:
=========================================================
Application Name: XYXZW4
Application Id: XYZ353WERX
Secret Key: XYZ86JBHHSD
Now I want regex to match only those "Application Name: value" which contain the "Secret Key: value" pair in windows powershell. I am not sure this may be the regex reference and it's not working on windows powerShell.
$input_path = ‘C:\Users\Steve\Downloads\input.txt’
$regex = '\s*Application Name:\s*.*\r?\n\s*(?=Application Id \(ClientId\):\s*.*\r?\n\s*Secret Key:\s*.*)|\s*Secret Key:\s*.*'
select-string -Path $input_path -Pattern $regex -AllMatches | Write-Output
All type of regexes work well on different platforms(tried few) but not on Windows powerShell.
The output should look like this:
Application Name: XYXZW3
Secret Key: XYZ86JBHHSD
Application Name: XYXZW4
Secret Key: XYZ86JBHHSD