I need to count the number of form fields in a string full of HTML. The problem is that this actually needs to be done in PHP, so no modules are allowed. Select, textarea, text, file and password elements are no big deal, but checkboxes and radio buttons are a problem.
So I need a regular expression that counts all input elements that have both the same name and the same type attributes as one field. I've made some progress, but it's hideously ugly so far and requires four separate calls because I can't seem to avoid hard-coding the order the attributes are expected in. Has anyone done this before?