Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You don't need LINQ - but you could 'enumerate' and use lambda to make it more generic...<br> (though not sure if any of this makes sense) </p> <pre><code>static IEnumerable&lt;string&gt; Split(this string text, Func&lt;char?, char?, char, int?&gt; shouldSplit) { StringBuilder output = new StringBuilder(); char? before = null; char? before2nd = null; foreach (var c in text) { var where = shouldSplit(before2nd, before, c); if (where != null) { var str = output.ToString(); switch(where) { case -1: output.Remove(0, str.Length -1); yield return str.Substring(0, str.Length - 1); break; case 0: default: output.Clear(); yield return str; break; } } output.Append(c); before2nd = before; before = c; } yield return output.ToString(); } </code></pre> <p>...and call it like this e.g. ... </p> <pre><code> static IEnumerable&lt;string&gt; SplitLines(this string text) { return text.Split((before2nd, before, now) =&gt; { if ((before2nd ?? 'A') == '\r' &amp;&amp; (before ?? 'A') == '\n') return 0; // split on 'now' return null; // don't split }); } static IEnumerable&lt;string&gt; SplitOnCase(this string text) { return text.Split((before2nd, before, now) =&gt; { if (char.IsLower(before ?? 'A') &amp;&amp; char.IsUpper(now)) return 0; // split on 'now' if (char.IsUpper(before2nd ?? 'a') &amp;&amp; char.IsUpper(before ?? 'a') &amp;&amp; char.IsLower(now)) return -1; // split one char before return null; // don't split }); } </code></pre> <p>...and somewhere... </p> <pre><code> var text = "ToSplitOrNotToSplitTHEQuestionIsNow"; var words = text.SplitOnCase(); foreach (var word in words) Console.WriteLine(word); text = "To\r\nSplit\r\nOr\r\nNot\r\nTo\r\nSplit\r\nTHE\r\nQuestion\r\nIs\r\nNow"; words = text.SplitLines(); foreach (var word in words) Console.WriteLine(word); </code></pre> <p>:)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload