in reply to Counting HTML form elements with a regular expression
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.
It's hard following you. Is your program perl, or PHP? If it's PHP, asking for help on a PHP site/newsgroup may bring better answers!
Anyway, what I understand is that you plan to use "perl compatible regexes" within PHP; but "perl compatible regexes" AREN'T perl. Regexes are a tiny part of perl really, and PHP so-called "compatible" implementation may vary considerably from the "Real Thing" (i.e. perl regexes). That's the first thing...
So I need a regular expression that counts all input elements
No, you probably don't. Parsing HTML with pure regexes is almost always a bad idea, unless you know precisely what limited HTML subset you'll actually have at input. Either you're working from within PHP, then you'll have to find some PHP module /library /tool /whatever to parse the HTML code, or you may call a perl program from your PHP code, and that perl program may use HTML::Parser or whatever perl module you may need.
|
|---|