Google Sheets SUMIFS – apply REGEXTRACT to sum_range?

I have the following Google Sheets table and want to calculate the total sums of various medications prescribed:

Type    Amount (in g)   Daily dosage (in g)
A       60              2
B       25 mg/capsule   30 pieces, 0-0-1 for 30 days
A       10              0.5

This is very easy for medication type A, as I can just look in column B.

My issue is that the entries associated with medication type B don’t only consist of digits, so I need to apply two REGEXTRACTs.


"(d+) pieces"

That is all fine and would work.

But how do I get around the issue that the sum_range in SUMIFS needs to be digits?

Because something like this would not work afaik:


I cannot change the way this data is entered and also don’t want to create additional columns if possible.