Next, we will use a pattern to match floating-point numbers, which may or may not have a decimal part.
import re
# Pattern to match floating-point numbers
pattern = r"[+-]?\d+(\.\d+)?"
# Example text containing floating-point numbers
text = "Temperatures range from -3.5 to +27.85 degrees."
matches = re.findall(pattern, text)
print(matches) # Output: ['-3.5', '+27.85']