List Info

Thread: Parsing HTML select/option text?




Parsing HTML select/option text?
user name
2006-12-12 09:10:14
I'm trying to parse the <select><option> HTML
construct.  The source
text looks like this:
...
<select name="xyz">
   <option value="abc">def</option>
   <option selected
value="abc2">def2</option>
...
</select>

While I have an expression for parsing the <option>
values which
results in exactly what I'm after (i.e. correct group
layout):

<option.*(?<selected>selected.*)?value="(?<
abc>d+)">(?<def>.*)</option>

my attempts to ensure that it only processes the correct
<select> tag
are failing.  I have a tag that matches just the correct
<select> tag:

<select.*?name="xyz">(n|.)*</select>

when combined, this produces:

<select.*?name="xyz">s*n(?:.*<option.*(
?<selected>selected.*)?value="(?<abc>d+)&q
uot;>(?<def>.*)</option>(n|.)*?)*?</selec
t>

however, this RE produces a individual match for whole
<select> group,
and individual matched groups for "abc" and
"def" groups.  I need to
retain the relationship between the abc and def values.

Any suggestions would be much appreciated!!!

J


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps-beta.google.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Parsing HTML select/option text?
user name
2006-12-12 16:20:03


not clear which one of two is the target string to parse:

<option value="abc">def</option>

OR

   <option selected
value="abc2">def2</option> 

OR both?


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://grou
ps-beta.google.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )