I'm trying to understand, why when I check my text document content (updated content, each time it is new string) with new insert for similar already exist string, for example if document content is:
hello world
hello, world
hello, world.
.hello, world
it founds new added string if it is already exists in content of file, if it is "hello world" or "hello, world", with simple checking condition, which notifies me if string already exist (and there is no any limitations or other conditions about last symbol in string):
List<string> wordsTyped = new List<string>();
if (wordsTyped.Contains(newStr))
{
string[] allLines = File.ReadAllLines(path);
}
but it doesn't notifies me if I have in my document content string with punctuation mark at the end or in the beginning of the string. For example if "hello, world." which is already exist, and new insert is similar "hello, world." or ",hello, world" it does not find it and notifies me as non exist.
If there is no solution to figure out with this problem and I am forced to remove last special symbol in the string, in this case would be good also to know, how to do it with regex for certain symbols dot, comma, hash, and apostrophe and keep everything else of course