My task is to find a specific word from a line by splitting with punctuation that can be anything (even a letter or any character in general). After finding the word, I have to return the word with punctuation that goes after it. I have come up with idea to firstly split line by punctuation, find each string that goes in between punctuation marks and then to split the same line only with words, but for some reason i only get the regular expression.
public static string FindWord2InLine(string line, string punctuation)
{
string[] parts = Regex.Split(line,"[" + punctuation + "]+");
string temp = "";
for (int i = 0; i < parts.Length; i++)
{
temp += Regex.Split(line, "[" + parts[i] + "]+");
}
return temp;
}