On Sun, 29 May 2005 at 07:39 GMT, cheng wrote: > hi all > a string like > > "(word1 & (Word2|woRd3))" > > how can i use the re to split it to > > ['word1', 'word2', 'word3']
This splits the string on one or more occurrences of any character that is not alphanumeric: import re str = "(word1 & (Word2|woRd3))" s = re.sub("[^a-zA-Z0-9]+"," ",str).split() -- Chris F.A. Johnson <http://cfaj.freeshell.org> ================================================================== Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress <http://www.torfree.net/~chris/books/cfaj/ssr.html> -- http://mail.python.org/mailman/listinfo/python-list