Jump to content

Recommended Posts

Posted (edited)

Hey I need to store to variable the two words that appear in the result. -The sentence could be longer but will contain "is a type of"

I do not need the origional string other than to get those two words.

So any way will work as long as its

$Variable1 is a type of $Variable2

Format.

#include <String.au3>
#include <Array.au3>

$String = "Did you know that Species is a type of Class"
_BreakDownString()

Func _BreakDownString()
    If StringInStr($String, "is a type of") = True Then
        $array1 = _StringExplode($String, " ", 0)
        _ArrayDisplay($array1, "StringExplode 0")
        For $x = 0 to UBound($array1) - 4
            If $array1[$x] = "is" And $array1[$x+1] = "a" And $array1[$x+2] = "type" And $array1[$x+3] = "of" Then
                $Variable1 = $array1[$x-1]
                $Variable2 = $array1[$x+4]
            EndIf
        Next
        ;$String = StringReplace($String, "is a type of", "")
        msgbox(0,"Result", $Variable1 & " " & $Variable2)
    EndIf
EndFunc

I am guessing there has to be a better way than what I came up with?

Thanks. -look forward to learning more!

Edit: Title Typo

Edited by Hatcheda

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
×
×
  • Create New...