Skip to content

Commit 47788b0

Browse files
andy31415ratgr
authored andcommitted
Fix regular expression for variable splitting. (project-chip#37493)
* Fix regular expression for variable splitting. Previous code tried to escape every character, however python linters complained about illegal escapes. The expression also seemed a bit complex, so a character set seems clearer. * Add brackets to force separator to also exist in the split
1 parent 777a609 commit 47788b0

File tree

1 file changed

+1
-2
lines changed
  • scripts/py_matter_yamltests/matter_yamltests

1 file changed

+1
-2
lines changed

scripts/py_matter_yamltests/matter_yamltests/parser.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1225,8 +1225,7 @@ def _config_variable_substitution(self, value):
12251225
# But some other tests were relying on the fact that the expression was put 'as if' in
12261226
# the generated code and was resolved before being sent over the wire. For such
12271227
# expressions (e.g 'myVar + 1') we need to compute it before sending it over the wire.
1228-
delimiter_regex = "(\ |\(|\)|\+|\-|\*|\/|\%)"
1229-
tokens = re.split(delimiter_regex, value)
1228+
tokens = re.split("([- ()|+*/%])", value)
12301229
if len(tokens) == 0:
12311230
return value
12321231

0 commit comments

Comments
 (0)