In Part 1, the author uses regex to find all instances of mul(N,N) and performs the appropriate extraction and math for each match.
For Part 2, the author uses regex to match do() and don't() occurrences and then isolates each stretch of valid statements to check for mul statements to parse.
The author implements an algorithm to handle various conditions, finds the start and end indices for each substring, and calculates the muls in the substrings.
The code generates the correct answer for both the example input and the author's puzzle input.