Getting all information between start and end strings in PowerShell, including the end string

74 Views Asked by At

I'm trying to edit a file with powershell, the thing is that I need all the information between two strings, this is currently what I have

$testText = Get-Content C:\Users\Administrator\Documents\test1\test1.txt

$pattern = '(?<=\DocMasterBOL>).+?(?=\DocFWImport>)'

[regex]::Matches($testText, $pattern).Value

where "DocMasterBOL>" is the beginningof the string and "DocFWImport>" the end of it

Do somebody knows how to do the same but adding the last part of the string? At the moment is adding results as I need them but without the end of the string "DocFWImport>"

0

There are 0 best solutions below