['PRE user_1/\n', '2016-11-30 11:43:32 62944 UserID-12345.jpg\n', '2016-11-28 10:07:24 29227 anpr.jpg\n', '2016-11-30 11:38:30 62944 image.jpg\n']
I have a list of string and i want to extract the 'name\n' part from each element and store it. For example i want to extract 'name\n' from mylist[0], where mylist[0] = 'PRE user_/n'. So user_1/
will be extracted and stored in a variable.
mylist = ['PRE user_1/\n', '2016-11-30 11:43:32 62944 UserID-12345.jpg\n', '2016-11-28 10:07:24 29227 anpr.jpg\n', '2016-11-30 11:38:30 62944 image.jpg\n']
for x in mylist:
i = 0
userid = *extract the 'name\n' from mylist[i]
print userid
i = i+1
How do i do this? Is Regular Expressions the way to do it?, if yes how do i implement it? A code snippet would be very helpful.