Note that there are some explanatory texts on larger screens.

plurals
  1. POCapture a part of a string that does not match another group (C# Regex)
    primarykey
    data
    text
    <p>I am working on a project that requires the parsing of "formatting tags." By using a tag like this: <code>&lt;b&gt;text&lt;/b&gt;</code>, it modifies the way the text will look (that tag makes the text bold). You can have up to 4 identifiers in one tag (<code>b</code> for bold, <code>i</code> for italics, <code>u</code> for underline, and <code>s</code> for strikeout).</p> <p>For example:</p> <p><code>&lt;bi&gt;some&lt;/b&gt; text&lt;/i&gt; here</code> would produce <b><i>some</b> text</i> here.</p> <p>To parse these tags, I'm attempting to use a RegEx to capture any text before the first opening tag, and then capture any tags and their enclosed text after that. Right now, I have this:</p> <p><code>&lt;(?&lt;open&gt;[bius]{1,4})&gt;(?&lt;text&gt;.+?)&lt;/(?&lt;close&gt;[bius]{1,4})&gt;</code></p> <p>That matches a single tag, its enclosed text, and a single corresponding closing tag.</p> <p>Right now, I iterate through every single character and attempt to match the position in the string I'm at to the end of the string, e.g. I attempt to match the whole string at <code>i = 0</code>, a substring from position 1 to the end at <code>i = 1</code>, etc.</p> <p>However, this approach is incredibly inefficient. It seems like it would be better to match the entire string in one RegEx instead of manually iterating through the string.</p> <p>My actual question is is it possible to match a string that does <em>not</em> match a group, such as a tag? I've Googled this without success, but perhaps I've not been using the right words.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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