public static string RightFromFirst(this StringExtensions.SubstrExtensionPoint sp, string substring, StringComparison comparison = StringComparison.Ordinal) { string extendedValue = sp.ExtendedValue; return(extendedValue.Safe <string, string>((string s) => { substring = substring.EmptyIfNull(); int num = (s.IndexOf(substring, comparison) >= 0 ? s.IndexOf(substring, comparison) + substring.Length : -1); if (num < 0) { return null; } return sp.Right(s.Length - num); }, null)); }
public static string RightFromLast(this StringExtensions.SubstrExtensionPoint sp, string substring, StringComparison comparison = StringComparison.Ordinal) { string extendedValue = sp.ExtendedValue; return(extendedValue.Safe <string, string>((string s) => { substring = substring.EmptyIfNull(); int length = -1; if (substring.IsEmpty()) { length = s.Length; } else if (s.LastIndexOf(substring, comparison) >= 0) { length = s.LastIndexOf(substring, comparison) + substring.Length; } if (length < 0) { return null; } return sp.Right(s.Length - length); }, null)); }