aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2020-05-22 02:43:13 +0200
committerache <ache@ache.one>2020-05-22 02:43:13 +0200
commit225e256acf0e841657ad2c30080bef83ab837cd5 (patch)
tree48f7281ca805006b79e82dc1a350871cfc209798
parentRename the list of sections (diff)
Regex matching
-rwxr-xr-xdicofr.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/dicofr.py b/dicofr.py
index 6ae3d3e..ea5741c 100755
--- a/dicofr.py
+++ b/dicofr.py
@@ -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)