CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions: Parsing values and names in HTML Dropdown: Edit Log


Mar 2, 2010, 11:02 AM

Views: 8382
Parsing values and names in HTML Dropdown

Hello everyone,
I'm having issues getting values and names out of a dropdown in HTML
the HTML is as follows:

<td class="label">Term</td>
<td class="right"><select name="ddlTerm" id="ddlTerm">
<option value=""></option>
<option value="10/SP">10/SP - Spring 2010</option>
<option value="10/SU">10/SU - All Summer 2010</option>
<option value="10/SA">10/SA - Summer A 2010</option>
<option value="10/SB">10/SB - Summer B 2010</option>
<option value="10/SC">10/SC - Summer C 2010</option>
<option value="10/SD">10/SD - Summer D 2010</option>
<option value="10/SE">10/SE - Summer E 2010</option>
<option value="10/FA">10/FA - Fall 2010</option>
<option value="11/SP">11/SP - Spring 2011</option>
<hr />

my regular expression is:
$content holds the html for the whole page

$content =~ /id="ddlTerm">\s*<option value=""><\/option>\s*<option value="(.*)">(.*)<\/option>/

this will give me $1 = 10/SP $2 = 10/SP - Spring 2010
but I also need the rest of the choices and would rather not hard code each line into the regexp (I need data from another dropdown with some 40-50 values in it) is there a good way to do this?

(This post was edited by twistedphrame on Mar 2, 2010, 11:03 AM)

Edit Log:
Post edited by twistedphrame (Novice) on Mar 2, 2010, 11:03 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives