how to split input line in custom format in python
<p>10.223.157.186 - - [15/Jul/2009:15:50:35 -0700] "GET /assets/js/lowpro.js HTTP/1.1" 200 10469</p>

<p>i have to take input as given below and have it as %h %l %u %t \"%r\" %>s %b</p>

<p>so that i can have 7 arguments :</p>

<p>%h is the IP address of the client</p>

<p>%l is identity of the client, or "-" if it's unavailable</p>

<p>%u is username of the client, or "-" if it's unavailable</p>

<p>%t is the time that the server finished processing the request. The format is [day/month/year:hour:minute:second zone]</p>

<p>%r is the request line from the client is given (in double quotes). It contains the method, path, query-string, and protocol or the request.</p>

<p>%>s is the status code that the server sends back to the client.</p>

<p>%b is the size of the object returned to the client, in bytes.</p>

<p>Take the input as a string. Assuming that the identity of the user can have spaces, but the username cannot,</p>

<pre><code>import re

full_string = input()   #python3

# First split at any one of [, ] or "
contents=re.split('[|]|"',full_string)

# Now, contents[0] = %h %l %u 
# contents[1] = %t 
# contents[2] = %r
# contents[3] = %&gt;s %b

# For a string, directly using the split function splits the string at the passed argument, which is a space here
content_h, content_l, content_u = contents[0].split(' ')[0], contents[0].split(' ')[1:-1], contents[0].split(' ')[-1]
content_s, content_b = contents[3].split[' '][0], contents[3].split[' '][1]
</code></pre>

python python-3.x input