Nim
From a first glance it was obviously a regex problem.
I'm using tinyre here instead of stdlib re library just because I'm more familiar with it.
import pkg/tinyre
proc solve(input: string): AOCSolution[int, int] =
var allow = true
for match in input.match(reG"mul\(\d+,\d+\)|do\(\)|don't\(\)"):
if match == "do()": allow = true
elif match == "don't()": allow = false
else:
let pair = match[4..^2].split(',')
let mult = pair[0].parseInt * pair[1].parseInt
result.part1 += mult
if allow: result.part2 += mult