a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')

Alice Bevan–McGregor alice at gothcandy.com
Thu Nov 25 11:04:56 CET 2010

Now that I think about it, and can be stripped using a callback 
function as the 'normalize' argument to my KeywordProcessor class:

def normalize(value):
    value = value.strip()

    if value.startswith("and"):
        value = value[3:]

    return value

parser = KeywordProcessor(',', normalize=normalize, result=list)

	— Alice.

More information about the Python-list mailing list