I have a
string word = "degree/NN";
What I want is to remove the "/NN" part of the word and take only the word "degree".
I have following conditions:
- The length of the word can be different in different occasions. (can be any word therefore the length is not fixed)
- But the word will contain the
"/NN"part at the end always.
How can I do this in C# .NET?
Implemented as an extension method:
Usage:
This takes into account that the unwanted part “/NN” is only removed from the end of the word, as you specified. A simple
Replacewould remove every occurrence of “/NN”. However, that might not be a problem in your special case.