Skip to content

Commit

Permalink
Fix regular expression for variable splitting. (project-chip#37493)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andy31415 authored Feb 10, 2025
1 parent df5ee33 commit da6a512
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions scripts/py_matter_yamltests/matter_yamltests/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,7 @@ def _config_variable_substitution(self, value):
# But some other tests were relying on the fact that the expression was put 'as if' in
# the generated code and was resolved before being sent over the wire. For such
# expressions (e.g 'myVar + 1') we need to compute it before sending it over the wire.
delimiter_regex = "(\ |\(|\)|\+|\-|\*|\/|\%)"
tokens = re.split(delimiter_regex, value)
tokens = re.split("([- ()|+*/%])", value)
if len(tokens) == 0:
return value

Expand Down

0 comments on commit da6a512

Please sign in to comment.