Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>My problem is that I need to split on + first, and then on ++. But if I split on + first, then the ++ instances are ruined and I end up with a mess.</p> </blockquote> <p>You could split on this regex first:</p> <pre><code>(?&lt;!\+)\+(?!\+) </code></pre> <p>That way, only the 'single' <code>+</code>'s are being split on, leaving you to parse the <code>++</code>'s. Note that I am assuming that there cannot be three successive <code>+</code>'s.</p> <p>The regex above simple says: "split on the '+' only if there's no '+' ahead or behind it".</p> <p><strong>Edit:</strong></p> <p>After reading that there can be more than 2 successive <code>+</code>'s, I recommend writing a small grammar and letting a parser-generator create a lexer+parser for your little language. ANTLR can generate C# source code as well.</p> <p><strong>Edit 2:</strong></p> <p>But before implementing any solution (parser or regex) you'd first have to define what <em>is</em> and what <em>isn't</em> valid input. If you're going to let more than two successive <code>+</code>'s be valid, ie. <code>1+++++5</code>, which is [<code>1++</code>, <code>+</code>, <code>++5</code>], I'd write a little grammar. See this tutorial how that works: <a href="http://www.antlr.org/wiki/display/ANTLR3/Quick+Starter+on+Parser+Grammars+-+No+Past+Experience+Required" rel="nofollow noreferrer">http://www.antlr.org/wiki/display/ANTLR3/Quick+Starter+on+Parser+Grammars+-+No+Past+Experience+Required</a></p> <p>And if you're going to reject input of more than 2 successive <code>+</code>'s, you can use either Lasse's or my (first) regex-suggestion.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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