mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
aider: Added comments to the regex pattern in aider/coder.py
to make it clearer.
# Context: USER: can you modify the code to add your earlier regex comments? ASSISTANT: Sure, I will add comments to the regex pattern in the `aider/coder.py` file to make it clearer. Here are the changes: ```python aider/coder.py <<<<<<< ORIGINAL pattern = re.compile( r"(^```\S*\s*)?^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+(\.[\w\s.-]+)*)\s+(^```\S*\s*)?^<<<<<<< ORIGINAL\n(.*?\n?)^=======\n(.*?)^>>>>>>> UPDATED", # noqa: E501 re.MULTILINE | re.DOTALL, ) ======= pattern = re.compile( # Optional: Matches the start of a code block (e.g., ```python) and any following whitespace r"(^```\S*\s*)?" # Matches the file path r"^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+(\.[\w\s.-]+)*)" # Optional: Matches the end of a code block (e.g., ```) and any following whitespace r"\s+(^```\S*\s*)?" # Matches the start of the ORIGINAL section and captures its content r"^<<<<<<< ORIGINAL\n(.*?\n?)" # Matches the separator between ORIGINAL and UPDATED sections and captures the UPDATED content r"^=======\n(.*?)" # Matches the end of the UPDATED section r"^>>>>>>> UPDATED", re.MULTILINE | re.DOTALL, ) >>>>>>> UPDATED ``` This should make the regex pattern more understandable.
This commit is contained in:
parent
f26a215ff4
commit
aca96263d8
1 changed files with 12 additions and 1 deletions
|
@ -344,7 +344,18 @@ class Coder:
|
||||||
# self.console.print(md)
|
# self.console.print(md)
|
||||||
|
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
r"(^```\S*\s*)?^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+(\.[\w\s.-]+)*)\s+(^```\S*\s*)?^<<<<<<< ORIGINAL\n(.*?\n?)^=======\n(.*?)^>>>>>>> UPDATED", # noqa: E501
|
# Optional: Matches the start of a code block (e.g., ```python) and any following whitespace
|
||||||
|
r"(^```\S*\s*)?"
|
||||||
|
# Matches the file path
|
||||||
|
r"^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+(\.[\w\s.-]+)*)"
|
||||||
|
# Optional: Matches the end of a code block (e.g., ```) and any following whitespace
|
||||||
|
r"\s+(^```\S*\s*)?"
|
||||||
|
# Matches the start of the ORIGINAL section and captures its content
|
||||||
|
r"^<<<<<<< ORIGINAL\n(.*?\n?)"
|
||||||
|
# Matches the separator between ORIGINAL and UPDATED sections and captures the UPDATED content
|
||||||
|
r"^=======\n(.*?)"
|
||||||
|
# Matches the end of the UPDATED section
|
||||||
|
r"^>>>>>>> UPDATED",
|
||||||
re.MULTILINE | re.DOTALL,
|
re.MULTILINE | re.DOTALL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue