Jump to content
Sign in to follow this  

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

Recommended Posts


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
SplashTextOn("Instances of MySubString", $x)


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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.