From b344adb53d15204420865fe134a40cae90eafd26 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 3 Oct 2023 11:22:09 +0200 Subject: [PATCH] fix regex --- changedetectionio/html_tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/changedetectionio/html_tools.py b/changedetectionio/html_tools.py index a7b1f366..7019ef14 100644 --- a/changedetectionio/html_tools.py +++ b/changedetectionio/html_tools.py @@ -10,7 +10,7 @@ import re # HTML added to be sure each result matching a filter (.example) gets converted to a new line by Inscriptis TEXT_FILTER_LIST_LINE_SUFFIX = "
" -PERL_STYLE_REGEX = r'^/(.*?)/([a-z]?)?$' +PERL_STYLE_REGEX = r'^/(.*?)/([a-z]*)?$' # 'price' , 'lowPrice', 'highPrice' are usually under here # all of those may or may not appear on different websites LD_JSON_PRODUCT_OFFER_SELECTOR = "json:$..offers" @@ -23,12 +23,14 @@ class JSONNotFound(ValueError): # Doesn't look like python supports forward slash auto enclosure in re.findall # So convert it to inline flag "(?i)foobar" type configuration def perl_style_slash_enclosed_regex_to_options(regex): + res = re.search(PERL_STYLE_REGEX, regex, re.IGNORECASE) if res: flags = res.group(2) if res.group(2) else 'i' regex = f"(?{flags}){res.group(1)}" else: + # Fall back to exactly what it contains as an option regex = f"(?i){regex}" return regex