{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Escape parentheses\n", "----\n", "\n", "Recursively escape unescaped parentheses in all `.txt` files within the specified directory and its subdirectories. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import re\n", "\n", "def escape_parentheses(file_path):\n", " with open(file_path, 'r') as file:\n", " content = file.read()\n", " # Escape unescaped opening parentheses\n", " content = re.sub(r'(?