tehon3299 Posted October 26, 2004 Posted October 26, 2004 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!!
Guest Py7|-|[]/\/ Posted October 26, 2004 Posted October 26, 2004 I'm not an expert at all, but I do know that you can do StringSplit to split it and then search for widgets.
scriptkitty Posted October 26, 2004 Posted October 26, 2004 (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 October 26, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
scriptkitty Posted October 26, 2004 Posted October 26, 2004 (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 October 26, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now