Here is another solution that uses string split based on <title> and and finds the pure title in between.
The idea is that first we check if the string contains elements <title> and . This can be relaxed if needed.
We add a pad to the front and end to handle the edge case. If we have both < title> and as start and end of the pure title, let's add a pad of '.' to the start and end of the text. This is needed to identify if the text contains only the valid title.
We then split the string into three segments.
Once the string has been split, we can remove the pad. By design, the padded character exists in the first and last index of the original text. The removal may not be needed if the text is a temporary variable and not needed later on.
Finally, the second element of the array contains the title that is pure.
We can refine the logic to handle cases where if ending is missing. In that case, certain assumption must be made.
string[] separatingStrings = { "<title>", "</title>"};
string text = "I was very <title> proud of my nickname throughout high school. but today I couldn’t be .any ¡ different to what my </title> nickname was. ";
System.Console.WriteLine($"Original text: '{text}'");
var hasStart = text.Contains(separatingStrings[0]);
var hasEnd = text.Contains(separatingStrings[1]);
if (hasStart && hasEnd)
{
text = "." + text+ ".";
string[] splitText = text.Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries);
text = text.Remove(text.Length -1,1).Remove(0,1);
System.Console.WriteLine($"{text.Length} substrings in text:");
foreach (var split in splitText)
{
System.Console.WriteLine($" {split}");
}
System.Console.WriteLine($"Final Title: \n\t{splitText[1]}");
}