I am trying to make a list from a text file (.txt) with python regular expression re. Some parts of the text are showing below.
146.204.224.152 - feest6811 [21/Jun/2019:15:45:24 -0700] "POST /incentivize HTTP/1.1" 302 4622\n197.109.77.178 - - kertzmann3129 [21/Jun/2019:15:45:25 -0700] "DELETE /virtual/solutions/target/web+services HTTP/2.0" 203 26554
May I know that how can I regex the text with a list format as:
{
"host_name": "146.204.224.152",
"name": "feest6811",
"time": "21/Jun/2019:15:45:24 -0700",
"method": "POST /incentivize HTTP/1.1"
},
..
..
..
I'm trying to regex with this pattern since I saw example with this pattern:
pattern="(?P<host_name>.*)(\ -\ )(?P<name>\w*)"
for item in re.finditer(pattern,'Text_data',re.VERBOSE):
print(item.groupdict())
Any suggestion to regex from this text.