regular expression in strings

David Bear david.bear at asu.edu
Fri Oct 10 21:21:51 EDT 2003


I'm trying to understand how regex's are interpreted out of strings
objects.  for example, If I have a string that has newline chars in
it, how can I get a re.split to respect where the newlines are?

>>> bs = 'in the begining, \n there were new lines, and in the end \nin lines'
>>> re.split('^in', bs)
['', ' the begining, \n there were new lines, and in the end \nin lines']
>>>

I want to split the string bs.  a '^in' should have also match \nin
where \n is the newline char.

Ultimately I have a large string buffer that I want to split at each
occurence of a particular regular expression, where the result
contains everything from the occurence of the regex till the end of
the 'line' 

any pointers?

David Bear
phone: 	480-965-8257
fax: 	480-965-9189
College of Public Programs/ASU
Wilson Hall 232
Tempe, AZ 85287-0803
 "Beware the IP portfolio, everyone will be suspect of trespassing"





More information about the Python-list mailing list