Sign in to follow this  
Followers 0
LovinItAll

How do I find the number of substrings in a string?

2 posts in this topic

I am trying to find the number of occurences of a string within the body tags of an HTML page. There will always be at least one and less than 22: (the code below is just one of many things I have tried. I also tried a Do loop -- which I think is what I want -- but no worky)

Func NumberOfStrings()

$StringToSearch = _IEBodyReadHTML($o_IE)
$x = 1
$y = 1
For $y = 1 to 22
    StringInStr ($StringToSearch, "MySubString", 0, $x)
    $x = $x + 1
         If @error = 1 Then  ; StringInStr() failed
             $y=22
         EndIf
Next
SplashTextOn("Instances of MySubString", $x)
sleep(10000)

EndFunc

Share this post


Link to post
Share on other sites



Never mind -- I figured it out. I need to stop messing with this stuff at 4 AM! :o

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