Is it possible to write a regular expression to check for a few conditions
<p>I can have the following variants of a <code>string</code>:</p>

<ul>
<li><code>text</code></li>
<li><code>[text]</code> or <code>[@text]</code></li>
<li><code>[OPTIONAL text]</code> or <code>[OPTIONAL @text]</code></li>
</ul>

<p>These are all possibilities. Is it possible via regular expression to easily extract the following information:</p>

<ul>
<li>What is the <code>text</code>,</li>
<li>Is it surrounded by <code>[</code> and <code>]</code>,</li>
<li>Is there an <code>OPTIONAL</code> word,</li>
<li>Is there an <code>@</code> before <code>text</code></li>
</ul>

<p>?</p>

<p>As for what I have done so far, I can </p>

<pre><code> var expressionMatch = Regex.Match(token, "[.*]");
 if (expressionMatch.Success)
 {
      // use now expressionMatch.Value;
      // check in the same way whether OPTIONAL word is there, etc.
 }

 // the input == text, all properties are false
</code></pre>

<p>But this is ugly. Is there a pretty / clean / simple way to do this?</p>