Delete specific lines from a txt file or xml file

Hi Champions,
I am working on a project where I have text file and a xml file which has more than 20000 line of code and my job is to automate to remove specific lines from that txt file as per requirement.In every line of the text a date is given in a order form.I have to recognize a specific date line and remove all the above lines of that. (Example:- if the date 24-08-2022 is at 10000 line number.I have to delete all the 10000 line before that date)
please explain the logic to automate this using ui path.

Thanks

Hello @Meezan_Murshid1 , Welcome to Uipath Community
Try regex replace method
kindly refer this flow, you may got some idea
Sample.xaml (5.9 KB)

System.Text.RegularExpressions.Regex.Replace(YourString,"[\S+\n\s]+(?="+DateString+")","").ToString

image

Thank You for your valuable reply.But this will not work because I Want to delete the entire line before date not just everything before that.
And its taking too much time to delete 10000 lines like this.
if have a better solution please share.
Thanks

Share the text file with us @Meezan_Murshid1

@Meezan_Murshid1
Try this
(?>\N+)\S\s

System.Text.RegularExpressions.Regex.Replace(YourString,"(?>\N+)[\S\s](?="+DateString+")","").ToString

It will delete the before line of the date.

image

Sharing the txt file here is not possible because its size of 90MB.