I have a regex which returns the correct results when I use the various on-line regex testing sites. However when I use the regex in a PowerShell script, it only returns a single line instead of multiple lines. I'm the hoping PowerShell experts here can tell me what I'm doing wrong. I'm using PowerShell v1.
This is my regex: https://regex101.com/r/eA5jB2/3
This is my powershell script:-
#Read the file
$FilePath = "testfile.txt"
$regex = '(?msi)^0[12][VM](?:[^\n]|\n(?!0[12][VM]|50|90))+'
get-content $FilePath | select-string -pattern $regex
The return is a single line
01Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 01 01 01
instead of
01Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 01 01 01
01=0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
01=5xxxxxxxxxxxxxxxxxxxxxxxxxxx