Extracting min and max salary from string What I want is to do is to extract min/max range of salary from a text which contains either hourly or annual salary.
import re

# either of the following inputs should work
input1 = &quot;$80,000 - $90,000 per annum&quot;
input2 = &quot;$20 - $24.99 per hour&quot;

salary_text = re.findall(&quot;[\$0-9,\. ]*-[\$0-9,\. ]*&quot;, input1)

if salary_text and salary_text[0]:
    range_list = re.split(&quot;-&quot;, salary_text[0])

    if range_list and len(range_list) == 2:
        low = range_list[0].strip(' $').replace(',', '')
        high = range_list[1].strip(' $').replace(',', '')

````
The , commas are a nice twist.
I feel you are stripping them a bit late,
as they don't really contribute to the desired solution.
Better to lose them from the get go.
Calling .findall seems to be overkill for your problem specification --
likely .search would suffice.

salary_text = re.findall(&quot;[\$0-9,\. ]*-[\$0-9,\. ]*&quot;, input1)


The dollar signs, similarly, do not contribute to the solution,
your regex could probably just ignore them if your inputs are fairly sane.
Or even scan for lines starting with $ dollar, and then the regex ignores them.

range_list = re.split(&quot;-&quot;, salary_text[0])


There is no need for this .split -- the regex could have done this for you already.
Here is what I recommend:
def find_range(text):
    if text.startswith('$'):
        m = re.search(r'([\d\.]+) *- *\$?([\d\.]+)', text.replace(&quot;,&quot;, &quot;&quot;))
        if m:
            lo, hi = m.groups()
            return float(lo), float(hi)
    return None, None


print(find_range('$80,000 - $90,000 per annum'))
print(find_range('$20 - $24.99 per hour'))

The raw string regex r'[\d\.]+' picks out one or more numeric characters,
which can include decimal point.
And putting ( ) parens around a regex makes it a capturing group --
we have two such groups here.
Finally,  *- *\$? lets us skip a single - dash with optional whitespace
and at most one optional $ dollar sign.