This is also done vijay by changing the code as below method_uri_protocol.append((m.group(1), m.group(2))).
Thanks a lot. The issues are solved now. Regards, Nithya. செவ்., 6 ஜூலை, 2021, பிற்பகல் 5:35 அன்று, Nithya Duraisamy <nithyadura...@gmail.com> எழுதியது: > > Hi Vijay, > > Changed the code as below. Now its coming like expected ['6245', '3985', > '4085'] > > l2= [] > for i in range(0, len(txt)): > s=txt[i] > l2 += re.findall("\d+$", s) > print(l2) > > Now please help me on the remaining one thing. > > [['GET', '/history/apollo/ HTTP/1.0'], ['GET', '/shuttle/countdown/ > HTTP/1.0'].....['GET', '/images/NASA-logosmall.gif HTTP/1.0']] > > should be coming as > > [('GET', '/history/apollo/ HTTP/1.0'), ('GET', '/shuttle/countdown/ > HTTP/1.0')...('GET', '/images/NASA-logosmall.gif HTTP/1.0')] > > > > செவ்., 6 ஜூலை, 2021, பிற்பகல் 5:21 அன்று, Nithya Duraisamy > <nithyadura...@gmail.com> எழுதியது: > > > > Hi Vijay, > > > > Now its coming as [['6245'], ['3985'], ['4085']] > > But expected is ['6245', '3985', '4085'] > > > > Likewise > > [['GET', '/history/apollo/ HTTP/1.0'], ['GET', '/shuttle/countdown/ > > HTTP/1.0'].....['GET', '/images/NASA-logosmall.gif HTTP/1.0']] > > > > should be coming as > > > > [('GET', '/history/apollo/ HTTP/1.0'), ('GET', '/shuttle/countdown/ > > HTTP/1.0')...('GET', '/images/NASA-logosmall.gif HTTP/1.0')] > > > > Any suggestions? > > > > Regards, > > Nithya. > > > > செவ்., 6 ஜூலை, 2021, பிற்பகல் 4:48 அன்று, Vijay Kumar B > > <vijayku...@zilogic.com> எழுதியது: > > > > > > ---- On Tue, 06 Jul 2021 16:25:55 +0530 Nithya Duraisamy > > > <nithyadura...@gmail.com> wrote ---- > > > > Hi All, > > > > Can anyone of your please help me to fix my code using re module? > > > > > > Hope this code, produces the required output. > > > > > > import os > > > import re > > > > > > txt = [ > > > '199.72.81.55 - - [01/Jul/1995:00:00:01 -0400] "GET /history/apollo/ > > > HTTP/1.0" 200 6245', > > > 'unicomp6.unicomp.net - - [01/Jul/1995:00:00:06 -0400] "GET > > > /shuttle/countdown/ HTTP/1.0" 200 3985', > > > '199.120.110.21 - - [01/Jul/1995:00:00:09 -0400] "GET > > > /shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0" 200 4085' > > > ] > > > > > > l1= [] > > > for s in txt: > > > m = re.match('.*"([A-Z]+) ((\S+) (\S+))".*', s) > > > if m: > > > l1.append([m.group(1), m.group(2)]) > > > > > > print(l1) > > > > > > l2= [] > > > for s in txt: > > > l2.append(re.findall("\d+$", s)) > > > > > > print(l2) > > > > > > Regards, > > > Vijay _______________________________________________ Chennaipy mailing list Chennaipy@python.org https://mail.python.org/mailman/listinfo/chennaipy