On Sun, Jun 1, 2008 at 6:48 AM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > A text document has special character strings defined as "." + "set of > characters" + ".". For example, ".sup." or ".quadbond." or ".degree." etc. > The length of the characters between the opening "." and closing "." is > variable. > > Assuming that you don't know beforehand all possible special character > strings, how do you find all such character strings in the text document?
Assuming the strings are non-overlapping, i.e. the closing "." of one string is not the opening "." of another, you can find them all with import re re.findall(r'\..*?\.', text) Kent _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
