[basic] compare string

0 favourites
  • 4 posts
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • how to compare 2 string that showed the result is almost true ...

    string 1 = Bill Gates

    string 2 = Bill

    result = almost true

    is there a good way to do this ????

  • You'd need to specify a bit more for what you consider 'almost true'. There are a bunch of string expressions, but from this example it's not clear what you want. Do you mean X letters are the same, X words, the words at the beginning, any words are the same...?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Or do you mean something like soundex? Im not so shure this can be done in c2.

    I'd go with blackhornet's way and go compare the first word.

  • take a look in the manual for find()

    something like   find(varwithtext, "stringtolookfor")

    if stringtolookfor does not occur in varwithtext, it should get you a -1

    For every occurence, it will add 1 to the result.

    I think this is the implementation of javascripts IndexOf

    variable = "long text with some stuff"

    find(variable, "stuff")

    should give you 0

    variable = "long stuffed text with some stuff"

    find(variable, "stuff")

    should give you 1

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)