Splitting a string

Fredrik Lundh fredrik at pythonware.com
Tue Feb 14 03:11:14 EST 2006


Dylan Moreland wrote:

> So I would try something like:
>
> pat = re.compile(r" (?:AND|OR|AND NOT) ")
> pat.split(string)

footnote: this yields:

    ['Smith, R.', 'White', 'Blue, T.', 'Black', 'Red', 'NOT Green']

(the | operator picks the first (leftmost) alternative that results in an
overall match.)

</F>






More information about the Python-list mailing list