MCPcopy Create free account
hub / github.com/RUC-NLPIR/WebThinker / extract_between

Function extract_between

scripts/run_web_thinker.py:128–140  ·  view source on GitHub ↗

Extracts text between two markers in a string.

(text, start_marker, end_marker)

Source from the content-addressed store, hash-verified

126
127
128def 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
142def format_search_results(relevant_info: List[Dict]) -> str:
143 """Format search results into a readable string"""

Callers 2

process_single_sequenceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected