using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSC.Blazor.Components.MarkdownEditor
{
internal static class StringExtensions
{
/// Extracts the string between the start tag and the end
/// The string where to search
/// The tag (only the tag itself: for example,
/// pass body if you want to extract the content between <body>
/// and </body).
/// A string with the content
internal static string ExtractTagContent(this string s, string tag)
{
// You should check for errors in real-world code, omitted for brevity
var startTag = "<" + tag + ">";
int startIndex = s.IndexOf(startTag) + startTag.Length;
int endIndex = s.IndexOf("" + tag + ">", startIndex);
return s.Substring(startIndex, endIndex - startIndex);
}
}
}