I trying to use:
price = str(re.findall(r"\$[^ ]+", msg_content))
and price value is:
XX.XX$ \ X.XX$ \ X$
$XX.XX \ $X.XX \ $X
I trying to use:
price = str(re.findall(r"\$[^ ]+", msg_content))
and price value is:
XX.XX$ \ X.XX$ \ X$
$XX.XX \ $X.XX \ $X
You can use
re.findall(r"\$\d+(?:\.\d+)?|\d+(?:\.\d+)?\$", msg_content)
Details:
\$\d+(?:\.\d+)?
- $
char, one or more digits and then an optional sequence of a .
and one or more digits|
- or\d+(?:\.\d+)?\$
- one or more digits and then an optional sequence of a .
and one or more digits and then a $
char.