views:

93

answers:

3

Hello,

Alright, so im going to jump in with my situation:

so i have string[] MyStringArray with "hello", "goodbye", "morning" in it, and now i have a normal string MatchString = "hel", now, on a specific trigger, id like to be able to loop through the strings in MyStringArray, and find the most likely match, and replace. so for instance, say i had the string "Hello, and good mor" and then i trigger the event, id want the resulting string to be "Hello, and good morning". same would be true for "i have got to go, go" -> "i have got to go, goodbye"

EDIT: i want on the trigger to only take the last word, separated by a space.

~code examples please! and thanks! - Xavier

A: 

errrr....

why doesn't "i have got to go, go" turn into "i have got to goodbye, gooodbye"?

and..

"Hello, and good mor" isn't "Hello, and goodbye morning"

Keith Nicholas
read my edits... i stated id only be taking the last word of the string
Xavier
ahhh, the edit helps.... match from the end finding characters, then use startswith and your string array
Keith Nicholas
A: 

You can use the .StartsWith() method, i.e.

foreach (var str in MatchArray)
{
    if (str.StartsWith(MatchString))
    {
        //it's a possible match
    }
}

But you have to deal with multiple matches seperately

Matt Warren
A: 

Intellisense: Home-Made - Based on Visual Studio By James Gupta

m3rLinEz