advanced
Complex Regular Expression for Log Parsing
Create a highly specific regular expression to parse and extract structured data from unstructured log files.
📝 Prompt İçeriği
Construct a single, verbose regular expression compatible with Python's `re` module to parse custom web server logs. The log format is defined as: [Timestamp in ISO 8601] [Level: INFO/ERROR/DEBUG] [IP Address] [Request Method] [URL Path] [Response Code] [Latency in ms] [User Agent string]. The regex must capture named groups for all these fields. Ensure it handles variable spacing and special characters in the URL and User Agent. After providing the regex, provide a breakdown explanation of how each capture group functions, specifically explaining how you account for the non-greedy matching required for the User Agent field to prevent overrunning to the next line.