Proposal to add 4 new APIs as extensions to the string class:
```c#
public static string SubstringUntil(this string s, string sub,
StringComparison comparison = StringComparison.Ordinal);
public static string SubstringAfter(this string s, string sub,
StringComparison comparison = StringComparison.Ordinal);
public static string SubstringUntilLast(this string s, string sub,
StringComparison comparison = StringComparison.Ordinal);
public static string SubstringAfterLast(this string s, string sub,
StringComparison comparison = StringComparison.Ordinal);
These methods would work by searching for the first (or last in case with `...Last` methods) occurrence of the string `sub` in the string `s` and return the substring before that occurrence (or after).
Example usages:
```c#
var a = "name = value";
var name = a.SubstringUntil("=").Trim(); // "name"
var value = a.SubstringAfter("=").Trim(); // "value"
```c#
var a = "foo;bar;pipe";
// Get the text in the middle
var bar = a.SubstringUntilLast(";").SubstringAfter(";"); // "bar"
```
This API provides a more straightforward approach for some basic parsing needs.
Example implementation:
If this is added, I think it would be important to offer Memory and Span-based versions too.
Small nit: XSLT has functions substring-before and substring-after. It might be nicer to name it SubstringBefore instead of SubstringUntil.
Before also makes it more explicit that the bound is exclusive.
Related: https://github.com/dotnet/corefx/issues/33543 and Utf8String.TryFind. If we exposed the latter TryFind method on string and ROS<char> then writing the Substring* methods proposed here would be very straightforward.
Most helpful comment
Beforealso makes it more explicit that the bound is exclusive.