How do I match a string in an array with variable?

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Array For each X element

    --> System Array.CurValue = globalvariable1

    The global variable is always lowercase with no non-alphanumeric or spaces.

    The array contains capitalized words with non-alphanumeric.

    Example:

    Array.CurValue could be Hello.

    globalvariable could be hello

    It does not recognize a match because of the uppercase and period. I originally had lowercase(Array.CurValue) but then this does not resolve the "."

    Then I tried find(aTexttoArray.CurValue, "[^a-z]"). Also did not work. I tried variations with the Regex expressions but could not get the right code. Any help would be appreciated. Thanks!

  • You can remove the period and convert to lowercase:

    lowercase(replace(Array.CurValue, ".", ""))

    If there are many such characters that you need to remove, it may be easier to use a local variable:

    set t to replace(Array.CurValue, ".", "")
    set t to replace(t, ",", "")
    set t to replace(t, ":", "")
    set t to replace(t, "!", "")
    set t to replace(t, "?", "")
    set t to lowercase(trim(t))
    

    Or use regexreplace()

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use Find with a Global Variable(String)

  • Thank you!!

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