Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've written a completely new answer, now that the problem is clarified:</p> <p>You <em>can</em> do this in a single regex. It is quite bulletproof, I think, but as you can see, it's not exactly self-explanatory, which is why I've commented it liberally. Hope it makes sense.</p> <p>You're lucky that .NET allows re-use of named capturing groups, otherwise you would have had to do this in several steps.</p> <pre><code>resultString = Regex.Replace(subjectString, @"(?: # Either match... (?&lt;before&gt; # (and capture into backref &lt;before&gt;) (?=\w*\p{L}) # (as long as it contains at least one letter): \w+ # one or more alphanumeric characters, ) # (End of capturing group &lt;before&gt;). \. # then a literal dot, (?&lt;after&gt; # (now capture again, into backref &lt;after&gt;) (?=\w*\p{L}) # (as long as it contains at least one letter): \w+ # one or more alphanumeric characters. ) # (End of capturing group &lt;after&gt;) and end of match. | # Or: \[ # Match a literal [ (?&lt;before&gt; # (now capture into backref &lt;before&gt;) [^\]]+ # one or more characters except ] ) # (End of capturing group &lt;before&gt;). \]\.\[ # Match literal ].[ (?&lt;after&gt; # (capture into backref &lt;after&gt;) [^\]]+ # one or more characters except ] ) # (End of capturing group &lt;after&gt;). \] # Match a literal ] ) # End of alternation. The match is now finished, but (?= # only if the rest of the line matches either... [^']*$ # only non-quote characters | # or [^']*'[^']*' # contains an even number of quote characters [^']* # plus any number of non-quote characters $ # until the end of the line. ) # End of the lookahead assertion.", "[${before}|${after}]", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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