title: AS3/Regular Expressions - Replacing segments of a string
body: <p>I have absolutely no knowledge in Regex whatsoever. Basically what I'm trying to do is have an error class that I can use to call errors (obviously) which looks like this:</p>
  
  <pre><code>package avian.framework.errors 
  {
      public class AvError extends Object
      {
          // errors
          public static const LAYER_WARNING:String = "Warning: {0} is not a valid layer - the default layer _fallback_ has been used as the container for {1}.";
  
          /**
           * Constructor
           * Places a warning or error into the output console to assist with misuse of the framework
           * @param err The error to display
           * @param params A list of Objects to use throughout the error message
           */
          public function AvError(err:String, ...params)
          {
              trace(err);
          }
      }
  }
  </code></pre>
  
  <p>What I want to be able to do is use the LAYER_WARNING like this:</p>
  
  <pre><code>new AvError(AvError.LAYER_WARNING, targetLayer, this);
  </code></pre>
  
  <p>And have the output be something along the lines of:</p>
  
  <pre><code>Warning: randomLayer is not a valid layer - the default layer _fallback_ has been used as the container for [object AvChild].
  </code></pre>
  
  <p>The idea is to replace <code>{0}</code> with the first parameter parsed in <code>...params</code>,  <code>{1}</code> with the second, etc.</p>
  
  <hr>
  
  <p>I've done a bit of research and I think I've worked out that I need to search using this pattern:</p>
  
  <pre><code>var pattern:RegExp = /{\d}/;
  </code></pre>