Jump to content

Recommended Posts

Posted

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

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

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.

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.

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
  • Recently Browsing   0 members

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