in reply to Perl HTML Form elements Filter
First split the HTML into chunks, and don't process bits of HTML outside < and >. Again, the wise person would use a module for this, but the rash fool would just split on ">". Then, for each chunk:
if (/name\s*=\s*['"]?(\w+)/i) { $name = $1; }
The only interesting thing here is the ['"]? which makes sure that you don't grab any quotes by accident. As far as I recall, form names should only have word characters, but I am ready to be corrected. I also don't know whether the spaces between html attribute names and values are legit or not. But unless you are writing the html yourself, you can trust some foolish user to put them in.
If you just want _form_ element names, you'll also first need to test for what sort of html tag you have:
if (/<input|<select|<textarea/i)
Cheers Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl HTML Form elements Filter
by skazat (Chaplain) on Dec 01, 2000 at 04:53 UTC | |
by markjugg (Curate) on Jan 31, 2001 at 22:16 UTC |