looping wrote: > On Oct 25, 8:49 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> >> needle = re.compile(r'create\s+or\s+replace\s+package(\s+body)?\s+', >> re.IGNORECASE) > > What I want here is a RE that return ONLY the line without the "body" > keyword. > Your RE return both. > I know I could use it but I want to learn how to search something that > is NOT in the string using RE.
You want a "negative lookahead assertion" then: >>> import re >>> s = """Isaac Newton ... Isaac Asimov ... Isaac Singer ... """ >>> re.compile("Isaac (?!Asimov).*").findall(s) ['Isaac Newton', 'Isaac Singer'] Peter -- http://mail.python.org/mailman/listinfo/python-list