Sign in to follow this  
Followers 0
werd

Regex help parsing an HTML tag

3 posts in this topic

Hi all, thanks for the continued responsiveness and help on all my Autoit questions!

I have some snippets of HTML where i'm trying to parse the "value=XXX" field:

<INPUT class="class 2" onselectstart="return me.function1;" id=WD0302  tabIndex=-1 readOnly maxLength=30 value="SOME Multi-word VALUE.COM" name=WD0302>
<INPUT class="class1" onselectstart="return me.functionN" id=abc123   name=WD0304 tabIndex=-1 readOnly maxLength=30 value=SingleWordValue>

The "value=" field can come anywhere within the <INPUT> tag, and if it's a multi-word value, then double quotes get placed around it. Otherwise, if it's single-worded, there are not quotation marks. I wish to extract a String array:

$array[n] = "Some Multi-word VALUE.COM"
$array[n+1] = "SingleWordValue"

I'm trying to use StringRegExp() for this purpose with:

(?i).* value="?(.+)"?.+

However, I'm not getting the desired effect because I seem to be getting tripped up with the optional quotes and/or spaces. Any help on tweaking (or re-writing) my string would help...

Share this post


Link to post
Share on other sites



Try this demo:

#include <IE.au3>

$oIE = _IE_Example("Form")
$colInputs = _IETagNameGetCollection($oIE, "INPUT")
$iIndex = 0
For $oInput In $colInputs
    ConsoleWrite($iIndex & ":  " & $oInput.value & @LF)
    $iIndex += 1
Next

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

yes that is embarrassingly simpler.

:)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0