Python:
import re
def extract_dollar_amount(text: str) -> int:
# Use a regex to find a number before the word "dollars"
match = re.search(r'sends\s+(\d+)\s+dollars', text, re.IGNORECASE)
if match:
amount = int(match.group(1))
return amount if amount > 0 else -1
return -1
# Examples
print(extract_dollar_amount("sends 50 dollars")) # Output: 50
print(extract_dollar_amount("sends 0 dollars")) # Output: -1
print(extract_dollar_amount("no money here")) # Output: -1