Skip to content

Commit 63d3528

Browse files
author
Florian Gardin
committed
Fix bugs when there is more than 10 features
1 parent 9c3e674 commit 63d3528

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

skrules/rule.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import re
2+
13
def replace_feature_name(rule, replace_dict):
2-
for key, value in replace_dict.items():
3-
rule = rule.replace(key, value)
4+
def replace(match):
5+
return replace_dict[match.group(0)]
6+
7+
rule = re.sub('|'.join(r'\b%s\b' % re.escape(s) for s in replace_dict),
8+
replace, rule)
49
return rule
510

611
class Rule:

0 commit comments

Comments
 (0)