I’m going crazy…
I’m tailing file and, if a string match my pattern, I want to output the match in a text file.
Everything works but, the output is truncated…
What am I doing wrong?
$MyMatch = "(A.{21})(.*?)(CALLID:(.*?)@10)"
demo
or
$MyMatch = "(A.{0,21})(.*?)(CALLID:(.*?)@10)"
or
$MyMatch = "(^.{0,21})(.*?)(CALLID:(.*?)@10)"
or
$MyMatch = "(^[sS]{0,21})(.*?)(CALLID:(.*?)@10)"
if I test regex on a shell works, if i run the script:
Get-Content "$file" -Tail 1 -Wait | foreach {
if ( $_ -match "REINVITE" ) {
$MSG = [regex]::match($_, $CALLID).Groups[1,4].Value
$MSG | Out-File "$OutFile"
}
}
This is the content of $OutFile:
This is the last line in $File:
24-07-09 05:19:18,938 I [PipelineThread-6 CallStateConnected 72] [SIGNAL ] CALLID:8805F91D-3CE44444444444444444444711EF-972CB613-C78A0EFF@10.49.86.173 - INVITE request received. REINVITE
Why the first 2 chars are skipped?