I am using Regex to select a string in a file. My problem is that Select-String is always using the whole line from the file. Here is my Code:
($a = Select-String -path C:\Users\boriv\Desktop\Patrick\regex\spec.ini -pattern "PD[0-9]{3}[A-Z]{2}\n")
My spec.ini file looks like this:
[SPEC LOCATIONS]
DV920_DataSource=Central Objects - DV920
DV920_Package=DV920FA
PD920_DataSource=Central Objects - PD920
PD920_Package=PD920FA
PS920_DataSource=Central Objects - PS920
PS920_Package=PS920FA
PY920_DataSource=Central Objects - PY920
PY920_Package=PY920FA
As output I need only the PD920FA from the line:
PD920_Package=PD920FA
Is there an alternative way to do this other than via Select-String?
I have also tried to use the Where Object but it didn't work.
My Regex works here is the Link: Regex
(?<=^DV920_Package=)PD\d{3}[A-Z]{2}if the value is always afterDV920_Package=at the start of the line. Add$at the end to make sure the end of string is tested.