By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,921 Members | 1,959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,921 IT Pros & Developers. It's quick & easy.

Re: splitting a string into an array using a time value

P: n/a
En Tue, 14 Oct 2008 18:08:53 -0300, Joe Python <jo******>
I want to find a way to split a string into an array using a time value.
s = r"""
8/25/2008 11:10:08 AM Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Sed imperdiet luctus nisl.
ipsum vel arcu gravida mattis. In mattis dolor id sem. Praesent
tortor non lacus. 0/3/2008 5:10:23 PM
ras quis ante id lacus sodales accumsan. Morbi bibendum iaculis
10/6/2008 4:39:55 PM Maecenas lectus libero,
tincidunt sed

I tried to use the pattern but its not working:
pattern = r'(\d+/\d+/\d+ \d+:\d+:\d+ .+)'
pat = re.compile(pattern)
result = re.split(pat,s)
The pattern must match the *separator* only. Try with:
pattern = r'\d+/\d+/\d+ \d+:\d+:\d+ (AM|PM)'

Gabriel Genellina

Oct 14 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.