ChrisO Posted September 22, 2010 Share Posted September 22, 2010 Hey all, I'm trying to parse a html page using StringRegExp to pull out some names that are useful to me. The portion of the html is: <select name='list_ck[]' size="10" multiple="multiple" style='width:250px'> <option value='jsmith'>John Smith</option><option value='esmith'>Eddie Smith</option> </select> The number of names can be any where from 0 to 4 and I need to grab each one. Here's what I have so far: $regexpResults = StringRegExp($dlPOc,"list_ck[^<]+(?:<option\svalue='\w+'>([^<]+)</option>)*\s",3) Am I over-complicating this? It seems like what I have should work but it only returns the last name (Eddie Smith) in this case. Thanks in advance. Link to comment Share on other sites More sharing options...
footswitch Posted September 22, 2010 Share Posted September 22, 2010 Take a look here Link to comment Share on other sites More sharing options...
kaotkbliss Posted September 22, 2010 Share Posted September 22, 2010 Did you try looping through your array of results? For $i=1 to Ubound($regexpResults)-1 msgbox(0,"",$regexpResults[$i]) Next if that goesn't work try the flag 1 instad of flag 3? 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
footswitch Posted September 22, 2010 Share Posted September 22, 2010 (edited) $html="<select name='list_ck[]' size=""10"" multiple=""multiple"" style='width:250px'>"&@CRLF& _ "<option value='jsmith'>John Smith</option><option value='esmith'>Eddie Smith</option> </select>" $array1=StringRegExp ($html, "(?s)(?i)<select name='list_ck(.+?)</select>",3) ; sets flag "(?s)", which means: "." matches any character including newline ; sets flag "(?i)", which means: case insensitive If @error==1 Then ConsoleWrite("-> No matches for first RegExp!"&@CRLF) _ArrayDisplay($array1) ; joins all the results in a single string: $string="" For $i=0 To UBound($array1)-1 $string&=$array1[$i] Next $array2=StringRegExp ($string, "(?s)(?i)<option value='.+?'>(.+?)</option>",3) If @error==1 Then ConsoleWrite("-> No matches for second RegExp!"&@CRLF) _ArrayDisplay($array2) EDIT: my browser is going nuts Edited September 22, 2010 by footswitch Link to comment Share on other sites More sharing options...
ChrisO Posted September 22, 2010 Author Share Posted September 22, 2010 Thanks both, as soon you pointed me towards using 2 passes with the regex, it became much simpler. Problem solved Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now