public static string SubstrAfterLast(this string input, string seq, SubstrOptions opts = SubstrOptions.Default) { if (input?.Length > 0 && seq?.Length > 0) { int index = input.LastIndexOf(seq, (opts & SubstrOptions.IgnoreCase) > 0 ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal); if (index >= 0) { if ((opts & SubstrOptions.IncludeSeq) == 0) { index += seq.Length; } return input.Substring(index); } } return (opts & SubstrOptions.RetInput) > 0 ? input : null; }
public static string SubstrAfterLast(this string input, string[] sequences, SubstrOptions opts = SubstrOptions.Default) { if (input?.Length > 0 && sequences?.Length > 0) { int idx = 0; for (int i = 0; i < sequences.Length; i++) { string seq = sequences[i]; if (seq?.Length > 0) { int pos = input.LastIndexOf(seq, idx, idx, (opts & SubstrOptions.IgnoreCase) > 0 ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal); if (pos >= idx && pos <= input.Length) { if ((opts & SubstrOptions.IncludeSeq) == 0) { pos += seq.Length; } idx = pos; } } } return input.Substring(idx); } return (opts & SubstrOptions.RetInput) > 0 ? input : null; }