Download augmentoolkit/generation_functions/extract_name.py from Leon4gr45/agent-0: direct link, hf CLI and curl.
- Browser
- Download file 642 Bytes
-
https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/generation_functions/extract_name.py
- Command line
-
hf download hf://spaces/Leon4gr45/agent-0/augmentoolkit/generation_functions/extract_name.py
-
curl -L -o extract_name.py https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/generation_functions/extract_name.py
642 Bytes
| import re | |
| def extract_name(str): | |
| # Regular expression to match 'Name:' followed by any characters until the end of the line | |
| name_regex = r"^Name:\s*([^\s]*)" | |
| # Searching in the multiline string | |
| match = re.search(name_regex, str, re.MULTILINE) | |
| if match: | |
| name = match.group(1) | |
| print(f"Extracted name: {name}") | |
| return name | |
| else: | |
| name_regex = r"Name: *([^\\]*)" | |
| # Searching in the multiline string | |
| match = re.search(name_regex, str, re.MULTILINE) | |
| if match: | |
| name = match.group(1) | |
| print(f"Extracted name: {name}") | |
| return name | |