in reply to Counting HTML form elements with a regular expression
Note - this may be unforgiving to some forms of sloppily coded HTML, but it should give you the general idea of how to go about parsing your form fields. I'd write you a PHP version too, but I need sleeeeeep...use strict; use warnings; my ($text, $tag, %tag, %c); $text = join '', <DATA>; while ($text =~ /<input (.*?)>/g) { $tag = $1; while ($tag =~ /(\w+)="(.*?)"/g) { $tag{lc($1)} = $2; } $c{"$tag{type}$tag{name}"} = 1; } for (sort keys %c) { print "$_\n"; } print scalar keys %c; __DATA__ <input type="radio" name="booger" value="bingo"> <input type="radio" name="booger" value="bongo"> <input type="radio" name="snot" value="bingo">
|
|---|