Regexdrill

Level 4: Extraction and cleanup Exercise 55 of 70 Free

Web server access log

A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.

The task

Each line is an access log entry: the client IP, a space, other fields, then a quoted request like "GET /index.html HTTP/1.1". Capture the IP (everything before the first space) in group 1, the uppercase method in group 2 and the path (up to the next space) in group 3.

What this exercise teaches

^(\S+) .*"([A-Z]+) (\S+) captures the three parts. Capturing the path with (.*)" would also pick up HTTP/1.1, and \w+ cannot capture a path that starts with a slash.

A hint if you get stuck

Anchor at the start and use \S+ for the IP. Skip to the quote with .*, then capture the method and the path with classes that cannot contain a space.

Try it now, free, no account needed

Every exercise on Regexdrill is free to try. Open it on the practice page, solve it, and get instant feedback with a hint. A free account adds the worked solution; Pro adds timed mode and the certificate.

Open this exercise

More exercises in Extraction and cleanup