diff --git a/helper/exercises.py b/helper/exercises.py index 4e3e5ae..99cdff7 100644 --- a/helper/exercises.py +++ b/helper/exercises.py @@ -49,7 +49,7 @@ def fix_exercise_ids(exercise, start_id): def replace_first_occurrences_with_placeholders(text: str, words_to_replace: list, start_id): for i, word in enumerate(words_to_replace, start=start_id): # Create a case-insensitive regular expression pattern - pattern = re.compile(re.escape(word), re.IGNORECASE) + pattern = re.compile(r'\b' + re.escape(word) + r'\b', re.IGNORECASE) placeholder = '{{' + str(i) + '}}' text = pattern.sub(placeholder, text, 1) return text