0

I have the following expressions.

The only difference between them is route (.gif and .html)

crystal.ipac.caltech.edu - - [17/Jul/1995:20:00:23 -0400] "GET /facts/faq04.gif HTTP/1.0" 200 27063

crystal.ipac.caltech.edu - - [17/Jul/1995:20:00:23 -0400] "GET /facts/faq04.html HTTP/1.0" 200 27063

And this is RegEx which is used for above ones. And it matchs to both of them.

"^([^\\>]+) (\\S+) (\\S+) \\[([\\w:/]+\\s[+\\-]\\d{4})\\] \"(.+?)\" (\\d{3}) (\\d+|-)"

But I need to exclude a first string with .gif extension. How can i do it?

Thanks

Arsen Ablaev
  • 431
  • 7
  • 13

1 Answers1

1

This may suit your needs:

"^([^\\>]+) (\\S+) (\\S+) \\[([\\w:/]+\\s[+\\-]\\d{4})\\] \"(((?!gif).)+?)\" (\\d{3}) (\\d+|-)"

Note the ((?!gif).) ... that's the negative look-around

sorak
  • 2,607
  • 2
  • 16
  • 24
  • 1
    Tip: It is more efficient to use `[0-9]` than it is to use `\d` . See https://stackoverflow.com/questions/16621738 – Josh Withee Dec 24 '17 at 05:12