Jump to content

Recommended Posts

Posted

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.

Posted

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 game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Posted (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 by footswitch

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...