Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save erdembayar/4d0d37b63be343538f98728cdac0584b to your computer and use it in GitHub Desktop.
Save erdembayar/4d0d37b63be343538f98728cdac0584b to your computer and use it in GitHub Desktop.
public static IEnumerable<int> FindAll(this string str, string sub)
{
if (sub.Length < 1)
yield break;
var index = 0;
while (true)
{
index = str.IndexOf(sub, index + 1, StringComparison.InvariantCultureIgnoreCase);
if (index == -1)
break;
yield return index;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment