From cf21ae22f1c385ec67d7281a512f56ccb6986b50 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 25 Aug 2023 17:15:21 +1000 Subject: [PATCH] Fix incorrect implementation of regex matching --- src/ifcopenshell-python/ifcopenshell/util/selector.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index f2dda2a9e5..097ea409ff 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -42,14 +42,14 @@ filter_elements_grammar = lark.Lark( location: "location" comparison value query: "query:" keys comparison value - pset: quoted_string | unquoted_string | regex_string - prop: quoted_string | unquoted_string | regex_string + pset: quoted_string | regex_string | unquoted_string + prop: quoted_string | regex_string | unquoted_string keys: quoted_string | unquoted_string attribute_name: /[A-Z]\\w+/ ifc_class: /Ifc\\w+/ - value: special | quoted_string | unquoted_string | regex_string + value: special | quoted_string | regex_string | unquoted_string unquoted_string: /[^.=\\s]+/ quoted_string: ESCAPED_STRING regex_string: "/" /[^\\/]+/ "/" @@ -428,7 +428,7 @@ class FacetTransformer(lark.Transformer): value = float(value) result = element_value == value elif isinstance(value, re.Pattern): - result = bool(value.match(element_value)) + result = bool(value.match(element_value)) if element_value is not None else False elif value in (None, True, False): result = element_value is value return result if comparison == "=" else not result