Hardly.StringHelpers.GetAfter C# (CSharp) Method

GetAfter() public static method

public static GetAfter ( this source, string searchToken, bool firstOrLastInstance = true ) : string
source this
searchToken string
firstOrLastInstance bool
return string
        public static string GetAfter(this string source, string searchToken, bool firstOrLastInstance = true)
        {
            if(source != null) {
                if(searchToken != null && searchToken.Length > 0) {
                    int i;
                    if(firstOrLastInstance) {
                        i = source.IndexOf(searchToken);
                    } else {
                        i = source.LastIndexOf(searchToken);
                    }
                    if(i >= 0) {
                        i += searchToken.Length;
                        if(i < source.Length) {
                            return source.Substring(i);
                        } else if(i == source.Length) {
                            return "";
                        }
                    }

                    return null;
                }

                Debug.Fail();
            }
            return null;
        }