Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Parity is generally very easy to decide using regular expressions. For example, this is an expression that matches any string with an even number of <code>A</code>s, but not an odd number:</p> <pre><code>(AA)* </code></pre> <p>So all you need to do is find the expression that matches only an odd number of <code>{</code>s and <code>}</code>s.</p> <pre><code>{({{)* }(}})* </code></pre> <p>(escaping the characters notwithstanding). So adding this idea to you current expression will yield something like</p> <pre><code>{({{)*(?&lt;key&gt;\w+)(?&lt;format&gt;:[^}]+)?}(}})* </code></pre> <p>However, this doesn't match the cardinality of braces on both sides. In other words, <code>{{{</code> will match <code>}</code>, because they're both odd. Regular expressions can't count things, so you're not going to be able to find an expression that matches cardinality like you want.</p> <p>Really, what you should be doing is parsing the strings with a custom parser that reads the string and counts instances of <code>{</code> but not instances of <code>{{</code> in order to match them against instances of <code>}</code> but not <code>}}</code> on the other side. I think you'll find this is how String formatters in .NET work behind the scenes anyway, as regular expressions aren't suited for parsing nested structures of any kind.</p> <p>Or you can use both ideas in concert: match potential tokens with a regular expression, then validate their braces balance using a quick check on the resulting match. That would probably end up being confusing and indirect, though. You're usually better off writing your own parser for this kind of scenario.</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. 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