Search Unity

comping string to list of array string

Discussion in 'Scripting' started by KhmerDude, Jan 12, 2016.

  1. KhmerDude

    KhmerDude

    Joined:
    Oct 18, 2012
    Posts:
    105
    Hi, I have a quick question regarding string, if my user where to ask my chatbot "your name" in the inputfield
    and my array list question expected contain "what's your name?" now we know that these question are the same, how can I make my bot recognize that beside using

    inputName = inputName.Replace("what's", "");
    inputName = inputName.Replace("?","");

    I only want to compare inuptName to certain keyword and ignore some.
    any help is appreciated.
     
  2. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    Code (CSharp):
    1. if (inputName.Contains("name") || inputName.Contains("your name"))
    also you can make before comparing inputName.ToLower();
     
  3. KhmerDude

    KhmerDude

    Joined:
    Oct 18, 2012
    Posts:
    105
    thanks sometime I overthink and forget stuff!