diff options
author | ache <ache@ache.one> | 2020-05-22 02:43:13 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2020-05-22 02:43:13 +0200 |
commit | 225e256acf0e841657ad2c30080bef83ab837cd5 (patch) | |
tree | 48f7281ca805006b79e82dc1a350871cfc209798 | |
parent | Rename the list of sections (diff) |
Regex matching
-rwxr-xr-x | dicofr.py | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -65,7 +65,16 @@ def matching(word): if word == w: matchingWord.append(w) else: - print("Error: Not implemented yet", file=sys.stderr) + if word[-1] != '/' or len(word) <= 2: + print("Erreur: Le format matching pour les regex est /MOT/", + file=sys.stderr) + return [] + import re + regex = re.compile(word[1:-1]) + + for w in listWord: + if regex.match(w): + matchingWord.append(w) return matchingWord @@ -75,6 +84,7 @@ if __name__ == '__main__': print("Erreur: Rechercher un mot", file=sys.stderr) exit() + # Si on n'arrive pas à trouver le dictionnaire if not exists(dico): if not exists(f'{DIR_PATH}/{dico}'): print('Error: No sqlite dictionnary', file=sys.stderr) |