1. A machine-readable medium that is not a transitory propagating signal, the machine readable medium including instructions that, when executed by a machine, cause the machine to preform operations comprising: identifying a quantification in a regular expression of source code; rewriting the quantification to be implemented by at least one of a counter state machine element of a target device or a set of general purpose state machine elements; identifying portions of the rewritten quantification that can be implemented by the counter state machine element; determining whether the target device has an available counter state machine element for the identified portions; and unrolling the identified portions if there is no available counter state machine element and assigning the identified portions to the available counter state machine element otherwise.