¨ì©³¦b²Ö¤°»ò°Ú¡H wrote: > I want "justice" and the words between the 2 nearest commas, which is > > establish justice > > All I can come up with is > > r",(.*?justice.*?)," > > but the result is > > in order to form a more perfect union, establish justice > > Apreciate any help.
",([^,]*justice[^,]*)," But this is simpler if you don't use a regular expression: >>> s = "We the people of the United States, in order to form a more perfect union, establish justice, insure domestic tranquility,......" >>> [phrase for phrase in s.split(',') if 'justice' in phrase ] [' establish justice'] -- http://mail.python.org/mailman/listinfo/python-list