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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



twistedphrame
Novice

Mar 2, 2010, 11:02 AM


Views: 3883
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:

Code
 <tr><td></td></tr> 
<tr>
<td>
<table>
<tr>
<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>
</select></td>
</tr>
</table>
<hr />
</td>
</tr>


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

Code
$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