New filters on the Home Feed, take a look!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
New Programmer ; Please help with exact string matching.
Post Body

Hey guys. Basically what I am doing is I am using a .txt file that contains a huge list of words, and importing it as a resource. Next, I'm assigning this .txt list of words to a string array, and split it (thus making it so that each word is located in a separate index). However, when I try to match the string "down", my program returns nothing. I also tried using Regex.IsMatch, however that too returns nothing.

With Regex:

namespace StringSplit_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] myList = Properties.Resources.dictionaryEN.ToString().Split('\n');

            string xy = "down";

            for (int x = 0; x < myList.Length; x  )
            {
                if ( Regex.IsMatch(myList[x], String.Format(@"^{0}$", xy)) == true)
                {
                    Console.WriteLine("Match Found!");
                    Console.WriteLine("Dictionary Value: {0}", myList[x]);
                    break;
                }
            }
            Console.ReadLine();
        }
    }
}

Without Regex:

namespace StringSplit_Practice
{
    class Program
    {
        static void Main(string[] args)
       {
            string[] myList = Properties.Resources.dictionaryEN.ToString().Split('\n');

            string str = "down";

           for (int x = 0; x < myList.Length; x  )
            {
                if ((String.Compare(myList[x], str) == 0))
                {
                    Console.WriteLine("Match Found!");
                    Console.WriteLine("Dictionary Value: {0}", myList[x]);
                    Console.WriteLine("Input Value: {0}", str);
                    break;
                }
            }
            Console.ReadLine();
        }
    }
}

Author
Account Strength
80%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
398
Link Karma
165
Comment Karma
233
Profile updated: 4 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 years ago