※ [EMAIL PROTECTED] (Thomas Nelson)》之銘言: > How about > my_string = "We the people of the United States, in order to form a > more perfect union, establish justice, insure domestic > tranquility,......" > print (x for x in my_string.split(",") if "justice" in x).next() > This isn't a regular expression, but it gives what you're looking for. > THN
Thanks a lot! I have never thought of that. But what if there's not only commas, but also periods and semicolons? I want to find words between 2 near by punctuations. I think it would make it difficult to use split instead of regular expression. -- [1;30;40m夫兵者不祥之器物或惡之故有道者不處君子居則貴左用兵則貴右兵者不祥之器非君子[m [1;30m之器不得已[37m[30m而用之恬淡為上勝而不美而美之者是樂殺人夫樂殺人者則不可得志於天下 [m[1;30m矣吉事尚左凶事尚右偏將軍居左上將軍居右言以喪禮處之殺人之眾以哀悲泣之戰勝以[m [1;30m喪禮處之道常[37m無名[30m樸雖小天下莫能臣侯王若能守之萬物將自賓天地相合以降甘露民莫[m [1;30m之令而自均始制有名名亦既有夫亦將知 [37m59-104-2-142.adsl.dynamic.seed.net.tw[30m海[m
-- http://mail.python.org/mailman/listinfo/python-list