feat: + move remove_white_spaces

This commit is contained in:
莘权 马 2024-02-01 19:28:05 +08:00
parent 34225d08b5
commit df8f929665
2 changed files with 16 additions and 16 deletions

View file

@ -603,3 +603,16 @@ def list_files(root: str | Path) -> List[Path]:
def parse_json_code_block(markdown_text: str) -> List[str]:
json_blocks = re.findall(r"```json(.*?)```", markdown_text, re.DOTALL)
return [v.strip() for v in json_blocks]
def remove_white_spaces(v: str) -> str:
"""
Removes white spaces from the provided string, excluding spaces within quotes.
Args:
v (str): The input string containing white spaces.
Returns:
str: The input string with white spaces removed, excluding spaces within quotes.
"""
return re.sub(r"(?<!['\"])\s|(?<=['\"])\s", "", v)