I'm trying to regex a file. I have tried these but I'm not good with regex.
((\|\n.*|\n))\d.*\n\s.*[0-9]{1,3}\s((\|\n.*|\n))\d\d\d\d\d\d\d\n\s\s\s\s\s\s\s\s\s\s[0-9]{1,3}\s((\|\n.*|\n))\d{7,8}\n\s.*[0-9]{1,3}\s\|\n\s.*\d{7}\n\s.*[0-9]{1,3}\s^.*\|\r?\n.*\r?\n[0-9]{1,3}$
I have a file that has lines like these
$00.00|0.00|0.00|||
8360657
68694
What I'm trying to do is figure out is the 3rd line is between 1 and 3 digits. If it's longer than 3 digits I don't care about it.
There is a lot more data in this file, and for each occurance of the above 3 lines I want to know all matches if the 3rd line in my example is 3 digits or less. How can I modify my regex to work?
Here is my example code of what I've tried:
$file = "C:\Users\user\Desktop\del2\file.le"
$content = gc $file -raw
$gRegex = "((\|\n.*|\n))\d{7,8}\n\s.*[0-9]{1,3}\s"
$content -match $guarantorRegex
I have got these to match using regex101.com however I'm not getting this to work in powershell...
What worked for me in the end:
$file = "C:\Users\user\Desktop\del2\D2341202.le"
$content = gc $file -raw
$guarantorRegex = "\|\r?\n[ ]{10}.*\r?\n[ ]{10}[0-9]{1,3}\s"
$content | select-string -Pattern $gRegex -AllMatches | % { $_.Matches } | % { $_.Value } > "C:\Users\user\Desktop\matches.txt"
^.*\|\r?\n.*\r?\n[0-9]{1,3}$regex101.com/r/lttbzU/1\n, your file must have Windows line endings, CRLF.^[ ]{10}.*\|\r?\n[ ]{10}.*\r?\n[ ]{10}[0-9]{1,3}$regex101.com/r/1w8BJP/1(?m)^[ ]{10}.*\|\r?\n[ ]{10}.*\r?\n[ ]{10}[0-9]{1,3}\$