import pandas as pd
r'\$?(?<!\d)(?:\d{1,3}(?:,\d{3})*|\d{4,})?.?\d+'
This is a regular expression (regex) pattern that can be used to match and extract monetary amounts from text.
The pattern starts with an optional $ character, which indicates that the monetary amount may be preceded by a dollar sign. This is followed by an optional group that consists of either of two patterns:
\d{1,3}(?:,\d{3})*: one to three digits followed by zero or more occurrences of a comma and three digits. This pattern is used to match amounts with thousands separators, such as 1,000 or 123,456,789. \d{4,}: four or more digits. This pattern is used to match amounts without thousands separators, such as 10000 or 123456. The pattern ends with an optional decimal point and one or more digits, which are used to match the fractional part of the amount.
The pattern also includes a lookbehind (?<!\d) at the beginning, which ensures that there is no digit immediately to the left of the pattern. This is used to prevent the pattern from matching digits that are part of a larger number, such as 123 in 123456.
Overall, this regex pattern can be used to match and extract monetary amounts from text, including amounts with or without thousands separators and fractional parts.