Good Day all,
I posted something similar earlier, so if you're running across this again, I apologize. This time around I'll be more specific and give you direct examples and portray exactly what I want. Basically, I need to make raw data look prettier:
str = '2011-06-1618:53:41222.222.2.22-somedomain.hi.comfw12192.10.215.11GET/965874/index.xls22233665588-0Mozilla/4.0 (compatible; MSI 5.5; Windows NT 5.1)'--55656-0.55-5874/659874540--'
more strings:
'2011-06-2150:36:1292.249.2.105-somedomain.hi.comfw12192.10.215.11GET/965874/ten.xls22233665588-0Mozilla/4.0 (compatible; MSI 6.0; Windows NT 5.1)'--55656-0.55-5874/659874540--'
'2011-01-1650:23:45123.215.2.215-somedomain.hi.comfw12192.10.215.11GET/123458/five.xls22233665588-0Mozilla/4.0 (compatible; MSI 7.0; Windows NT 5.1)'--55656-0.55-5874/659874540--'
'2011-02-1618:16:54129.25.2.119-thisdomain.hi.comfw12192.10.215.11GET/984745/two.xls22233665588-0Mozilla/4.0 (compatible; MSI 7.0; Windows NT 5.1)'--55656-0.55-5874/659874540--'
'2011-08-0525:22:16164.32.2.111-yourdomain.hi.comfw12192.10.215.11GET/85472/one.xls22233665588-0Mozilla/4.0 (compatible; MSI 8.0; Windows NT 5.1)'--55656-0.55-5874/659874540--'
IN THE DEBUGGER:
import re
str = '2011-06-1618:53:41222.222.2.22-somedomain.hi.comfw12192.10.215.11GET/965874/index.xls22233665588-0Mozilla/4.0 (compatible; MSI 5.5; Windows NT 5.1)'--55656-0.55-5874/659874540--'
domain = re.compile('^.*?(?=([fw].+?))')
domain.search(str).group()
'2011-06-1618:53:41222.222.2.22-somedomain.hi.com'
domain = domain.search(str).group()
So for getting the domain, I need to get rid of everything before the dash(-), right before the domain name. I can look for that value with this RE ([0-9]{3,5}).([0-9]{1,3}.){2}[0-9]{1,3}[-] But I don't know how to say, find that value and return everything AFTER it, but BEFORE fw12.
at the end of the day, i want those strings to look like this, using comma(, ) as a delimiter:
2011-08-05, 25:22:16, 164.32.2.111, yourdomain.hi.com, GET/85472/one.xls, Mozilla/4.0 (compatible; MSI 8.0; Windows NT 5.1)