Extracts text between two markers in a string.
(text, start_marker, end_marker)
| 126 | |
| 127 | |
| 128 | def extract_between(text, start_marker, end_marker): |
| 129 | """Extracts text between two markers in a string.""" |
| 130 | try: |
| 131 | pattern = re.escape(end_marker[::-1]) + r"(.*?)" + re.escape(start_marker[::-1]) |
| 132 | # Run pattern matching with timeout |
| 133 | matches = re.findall(pattern, text[::-1], flags=re.DOTALL) |
| 134 | if matches: |
| 135 | return matches[0][::-1].strip() |
| 136 | return None |
| 137 | except Exception as e: |
| 138 | print(f"---Error:---\n{str(e)}") |
| 139 | print(f"-------------------") |
| 140 | return None |
| 141 | |
| 142 | def format_search_results(relevant_info: List[Dict]) -> str: |
| 143 | """Format search results into a readable string""" |
no outgoing calls
no test coverage detected