Sign in to follow this  
Followers 0
tehon3299

Partial String Match

4 posts in this topic

I am trying to figure out how to make partial matches of strings...For example, I want to write an if to check if the string, "iLoveWidgets" contains the word "Widgets"...Can this be done?? I cannot find out how to do this anywhere!

Thanks!!

Share this post


Link to post
Share on other sites



I'm not an expert at all, but I do know that you can do StringSplit to split it and then search for widgets.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

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