splitting file/content into lines based on regex termination
Piet van Oostrum
piet at vanoostrum.org
Sat Nov 9 20:05:03 EST 2013
bruce <badouglas at gmail.com> writes:
> hi.
>
> thanks for the reply.
>
> tried what you suggested. what I see now, is that I print out the
> lines, but not the regex data at all. my initial try, gave me the
> line, and then the next items , followed by the next line, etc...
exp = re.compile(r"(<br>#\d+\s*/\s*\d+#\d+#)")
exp.split(s)
=>
['10116#000#C S#S#100##001##DAY#Fund of Computing#Barrett,\nWilliam#3#MWF<br>#08:00am<br>#08:50am<br>#3718 HBLL ',
'<br>#45 /\n58#0#',
'10116#000#C S#S#100##002##DAY#Fund of Computing#Barrett,\nWilliam#3#MWF<br>#09:00am<br>#09:50am<br>#3718 HBLL ',
'<br>#9 /\n58#0#',
'10178#000#C S#S#124##001##DAY#Computer Systems#Roper,\nPaul#3#MWF<br>#11:00am<br>#11:50am<br>#1170 TMCB ',
'<br>#41 /\n145#0#',
'10178#000#C S#S#124##002##DAY#Computer Systems#Roper,\nPaul#3#MWF<br>#2:00pm<br>#2:50pm<br>#1170 TMCB ',
'<br>#40 /\n120#0#',
"01489#002#C S#S#142##001##DAY#Intro to Computer\nProgramming#Burton, Robert <div class='instructors'>Seppi, Kevin<br\n/></div>"]
--
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
More information about the Python-list
mailing list