0

I'm having this piece of text

2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/Documents/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)    Downloading page WebParts...
2/27/2020 7:00:44 PM  138 (6036)     Downloading page web parts completed. 1 web parts successfully downloaded.
2/27/2020 7:00:44 PM  138 (6036)     Downloading page content...
2/27/2020 7:00:44 PM  138 (6036)       Restarting from position 8312...
2/27/2020 7:00:44 PM  138 (6036) Error:  error
double double
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/sdadasda/Forms/All.aspx...
2/27/2020 7:00:44 PM  138 (6036) Error: Unspecified error
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/21312332131/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/123/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/123/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/Documeents/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/wr/Forms/All.aspx...

I need to return all lines with:

  • "Downloading view page:" part in them
  • no "Documents" word in them.

Expected result:

2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/21312332131/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/123/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/123/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/Documeents/Forms/All.aspx...
2/27/2020 7:00:43 PM  138 (6036)   Downloading view page: /personal/test/wr/Forms/All.aspx...

I tried negative lookahead and regular [^Docuemnts]. None seems to work.

(\(\d+\)).*Downloading view page:\s\/personal\/\S+\/[^(Documents)]\/F
(\(\d+\)).*Downloading view page:\s\/personal\/\S+\/(?!Documents)\/F
Kaustubh Khare
  • 3,280
  • 2
  • 32
  • 48
feedthemachine
  • 592
  • 2
  • 11
  • 29

1 Answers1

1

One easy solution would be to just use a single negative lookahead to exclude Documents:

^(?!.*\bDocuments\b).*\bDownloading view page:(?!\S).*$

Demo

Here is a full explanation of the regex pattern:

^                           from the start of the string
(?!.*\bDocuments\b)         assert that "Documents" does not occur anywhere in the line
.*\bDownloading view page:  then match "Downloading view page:"
(?!\S)                      assert that what follows is either whitespace or end of string
.*                          match the rest of the line
$                           until the end of the string
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360