title: Reg exp. with optional parameters
body: <p>I'm in need of reg-exp to match some text and then resulting in a CTA-button. What I want is, that the following text will result in the output:</p>
  
  <h2>EXAMPLE 1</h2>
  
  <pre><code>{BUTTON text="(some text)" link="(some link)" target="(target, OPTIONAL)" class="(classes, OPTIONAL)"}
  
  &lt;a href="(some link)" target="(target)" class="$4"&gt;(some text)&lt;/a&gt;
  </code></pre>
  
  <h2>EXAMPLE 2</h2>
  
  <pre><code>{BUTTON text="(some text)" link="(some link)" target="(target, OPTIONAL)"}
  
  &lt;a href="(some link)" target="(target)"&gt;(some text)&lt;/a&gt;
  </code></pre>
  
  <h2>EXAMPLE 3</h2>
  
  <pre><code>{BUTTON text="(some text)" link="(some link)"}
  
  &lt;a href="(some link)"&gt;(some text)&lt;/a&gt;
  </code></pre>
  
  <p>My own "solution" is this, but I don't think it's the "correct" way to do it - in other words i'm quite certain, it has flaws!</p>
  
  <pre><code>{BUTTON text="([a-zA-Z0-9 ]+)" link="([A-Za-z0-9\/\:\.\?\=]+)"( target=")?([a-zA-Z\_]+)?(")? ( class=")?([a-zA-Z\_]+)?(")?}
  </code></pre>