Jump to content

Partial String Match


Recommended Posts

I love stringsplit, but it only splits by one character. Larry is right about StringInStr, with stands for String In String, It returns the Position of one striing inside of anouther. quiite handy.

While you are reading about it, play with StringTrimLeft, StringLen, and StringTrimRight. They come in real handy.

edit: also to note, what also comes in handy is the optiional setting:

occurance [optional]Which occurance of the substring to find in the string. Use a negative occurance to search from the right side. The default value is 1 (finds first occurance).

Say you want to know how many times I typed the word "in" in this post. 20count case sensitive, 22 for caps as well. Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

btw it doesn't count on its own, I copied the text into clipboard and used this.

$string=clipget()
for $i=1 to 999 
$x=stringinstr($string,"in",0,$i)
if $x<1 then exitloop; jumps out of loop when no longer found
next
$x=stringinstr($string,"in",0,$i-1)
msgbox(1,"Last occurance " & $x,"Total is " & $i-1)
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...