Source: http://www.tal.univ-paris3.fr/cours/td-deug1-0203/ExercicesPWTenword.pdf