Jump to content

Grab the last digits of a <span> [Solved]


Recommended Posts

What would be the best way to grab the last digits of this <span>? One of the problems I know I am going to have is sometimes it will be 1 digit other times it might be 3. 

span.PNG.3ff27f3b9501d0d4f6bc6dc3ad945dd6.PNG

I am trying to get the list of spans and I get this error.

error.thumb.PNG.a1953092041007875064097cd57e8bb9.PNG

 

$oInputs = _IETagNameGetCollection($oIE, "span")
$sTxt = ""
For $oInput In $oInputs
    $sTxt &= $oInput.Innertext & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Form Input Type", "Form: " & $oInput.form.name & @CRLF & @CRLF & "         Types :" & @CRLF & $sTxt)

 

Edited by SkysLastChance

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

Your trying to use the object outside of the loop, just use something like StringRight($oInput.Innertext, 1)

Edit:

Whoops didn't read your post correctly, try something like

Local $iCount, $sInnerText = "Showing items 1-7 of 1"
If StringInStr($sInnerText, "Showing items ") Then
    $iCount = Number(StringTrimLeft($sInnerText, StringInStr($sInnerText, " of ", 0, -1) + 3))
    If $iCount > -1 Then MsgBox(4096, "Item Count", "No. of Items = " & $iCount)
EndIf

 

Edited by Subz
Link to comment
Share on other sites

Do you mean that?

;~ Local $oInputs = _IETagNameGetCollection($oIE, "span")
;~ Local $sTxt
;~ For $oInput In $oInputs
;~     $sTxt &= $oInput.Innertext & @CRLF
;~ Next

#include <MsgBoxConstants.au3>

$sTxt = "Showing items 1-7 of 7" & @CRLF & _
        "Showing items 1-10 of 16" & @CRLF & _
        "Showing items 11-16 of 16" & @CRLF & _
        "Showing items 1-100 of 268" & @CRLF & _
        "Showing items 101-200 of 268" & @CRLF & _
        "Showing items 201-268 of 268"
$sTxt = StringRegExpReplace($sTxt, "(?m).*(?<=\D)(?=\d+$)", "")
MsgBox($MB_SYSTEMMODAL, "Form Input Type", "Numbers at end of <span>s :" & @CRLF & $sTxt)

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • 2 weeks later...

This was more than enough help. Thank you everyone!

I like to post what I used for future reference and anybody else that may need help. This is what I went with.

$oInputs = _IETagNameGetCollection($oIE, "span")
$sTxt = ""
For $oInput In $oInputs
    $sTxt &= $oInput.Innertext & @CRLF
 Next

IF  StringInStr($sTxt, "Showing items ") Then
    $iCount = Number(StringTrimLeft($sTxt, StringInStr($sTxt, " of ", 0, -1) + 3))
    If $iCount > -1 Then MsgBox(4096, "Item Count",$iCount)
EndIf

 

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
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
 Share

×
×
  • Create New...