splitting a string into an array using a time value

Joe Python jopython at gmail.com
Tue Oct 14 23:08:53 CEST 2008


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 dictum
tortor non lacus.  0/3/2008 5:10:23 PM
      ras quis ante id lacus sodales accumsan. Morbi bibendum iaculis purus
10/6/2008 4:39:55 PM Maecenas lectus libero,
      tincidunt sed
      """
I am looking for an output in the form of an array as follows:

resulting-array = [ 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 dictum
tortor non lacus.,

     0/3/2008 5:10:23 PM       ras quis ante id lacus sodales accumsan.
Morbi bibendum iaculis purus,

     10/6/2008 4:39:55 PM Maecenas lectus libero,   tincidunt sed ]

     Note: there is an element corresponding to each time entry in the array

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)

- Joe Python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081014/148eccb7/attachment.html>


More information about the Python-list mailing list