csharp/1ZouLTReX1/FP-MOG/top%20down%20shooter/Assets/Scripts/Utils/StringExtensionMethods.cs

StringExtensionMethods.cs
// Convenience functions for strings
public static clast StringExtensionMethods
{
    public static string AfterLast(this string str, string sub)
    {
        var idx = str.LastIndexOf(sub);
        return idx < 0 ? "" : str.Substring(idx + sub.Length);
    }

    public static string BeforeLast(this string str, string sub)
    {
        var idx = str.LastIndexOf(sub);
        return idx < 0 ? "" : str.Substring(0, idx);
    }

    public static string AfterFirst(this string str, string sub)
    {
        var idx = str.IndexOf(sub);
        return idx < 0 ? "" : str.Substring(idx + sub.Length);
    }

    public static string BeforeFirst(this string str, string sub)
    {
        var idx = str.IndexOf(sub);
        return idx < 0 ? "" : str.Substring(0, idx);
    }

    public static int PrefixMatch(this string str, string prefix)
    {
        int l = 0, slen = str.Length, plen = prefix.Length;
        while(l