-4

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
Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91
Snirki
  • 9
  • 1

1 Answers1

0

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.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563