0

I have a string like:

[10/Jul/2019:00:45:18 +0900] "POST /auth/identity/success HTTP/1.1"

I want to extract everything inside ""

for the date I used re.compile('\[(\d+\/\w\w\w\/\d\d\d\d:\d\d:\d\d:\d\d\s\+\d\d\d\d)\]')

for the string inside "" instead of matching one by one I am hoping if there is way to match say 10 character with one regex command.

I've done re.compile('(\"[A-Z]\s[\w\/]\s[\w\/\"])')

What I am trying to do:

\" matches "
[A-Z] matches 4 character (but actually match only one character)
\s for whitespace
[\w\/] for matching everything in /auth/../success
[\w\/\"] for HTTP/1.1"
haneulkim
  • 2,445
  • 2
  • 12
  • 33
  • 2
    Looks like you're new to regex. I recommend experimenting and troubleshooting here: https://regex101.com/ . To answer your question about matching characters multiple times, what you're looking for are quantifiers. Put `{n}` after a character or group and it will match n times. `a{3}` matches `aaa` for example. – CAustin Oct 30 '19 at 00:50
  • but problem is number of character will be different for each line – haneulkim Oct 30 '19 at 00:51
  • 2
    So use `+` (1 or more) or `*` (0 or more). – Wiktor Stribiżew Oct 30 '19 at 00:52

0 Answers0