Jump to content

Recommended Posts

Posted

i am trying to get number from string using this code :

#include <IE.au3>
$oIE = _IEAttach ("Edu.corner")
Local $aName = "Student name & Code:", $iaName = "0"
Local $oTds = _IETagNameGetCollection($oIE, "td")
For $oTd In $oTds
    If $oTd.InnerText = $aName Then
        $iaName = $oTd.NextElementSibling.InnerText
        $iGet = StringRegExpReplace($iaName, "\D", "")
     EndIf
Next
MsgBox(0, "", $iGet)

it was get number like 52503058

But, I want to get only student code 5250. (Different student have different code, sometime its 3 digits, Sometime 4)

area.JPG.fff7ca29de5bc44876cf45439e8e962b.JPG
 

Posted

@jmp

You could use something like this:

ConsoleWrite(StringRegExp($oTd.InnerText, "[^:]+\h*:\h*(\d{3,4})\h*\(", $STR_REGEXPARRAYMATCH) & @CRLF)

By the way, what kind of sense do those variables names have?

$aName is not an array (the "a" should stand for array), and $iGet is not supposed to contain an integer value (the "i" should stand for integer), but a string.

Click here to see my signature:

  Reveal hidden contents

 

  • 4 weeks later...

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
×
×
  • Create New...