C# function for cutting texts without cut words

Here is a function for cutting texts without cut words. After setting a character number to cut, the function will search the next space, returning the last word complete.

For HTML codes, we will need a function to sanitize the text before doing the magic.

public static string CutText(string text, int numberOfCharacters)
{
    string strReturn = NoHtml(text).Trim();

    text = NoHtml(text).Trim();

    if (text.Substring(0, text.Length).Trim().IndexOf(" ") > 0)
        if (text.Length >= numberOfCharacters + 1)
            if (text.Substring(0, numberOfCharacters + 1).Trim() != " ")
            {
                int spacePosition = text.Substring(0, numberOfCharacters - 1).Trim().LastIndexOf(" ");
                if (spacePosition > 0)
                    strReturn = text.Substring(0, spacePosition).Trim();
                else
                {
                    int spacePosition2 = text.Substring(0, text.Length).Trim().IndexOf(" ");
                    if (spacePosition < text.Substring(0, spacePosition2).Trim().IndexOf(" "))
                        strReturn = text.Substring(0, numberOfCharacters).Trim();
                    else
                        strReturn = text.Substring(0, spacePosition2).Trim();
                }
            }

    return strReturn + " [...]";
}

Cleaning text for HTML tags

public static string NoHtml(string text)
{
    if (System.Text.RegularExpressions.Regex.IsMatch(text, "<.*?>"))
        return System.Text.RegularExpressions.Regex.Replace(text, "<.*?>", " ");

    return text;
}

Get Youtube ID from URL string in C#

public static string _pegarIDYoutube(string URLYoutube)
{
    var regexString = @"^(http(s?):\/\/)?(www\.)?youtu(be)?\.([a-z])+\/(watch(.*?)(\?|\&)v=)?(.*?)(&(.)*)?$";

    Match match = Regex.Match(URLYoutube, regexString,
    RegexOptions.IgnoreCase);

    if (match.Success)
        return match.Groups[9].Value;
    else
        return null;
}