Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6015995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:55:11+00:00 2026-05-23T02:55:11+00:00

I have absolutely no knowledge in Regex whatsoever. Basically what I’m trying to do

  • 0

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:

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);
        }
    }
}

What I want to be able to do is use the LAYER_WARNING like this:

new AvError(AvError.LAYER_WARNING, targetLayer, this);

And have the output be something along the lines of:

Warning: randomLayer is not a valid layer - the default layer _fallback_ has been used as the container for [object AvChild].

The idea is to replace {0} with the first parameter parsed in ...params, {1} with the second, etc.


I’ve done a bit of research and I think I’ve worked out that I need to search using this pattern:

var pattern:RegExp = /{\d}/;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:55:12+00:00Added an answer on May 23, 2026 at 2:55 am

    Using the g flag in RegExp you can create an array containing all of your {x} matches, then loop through this array and replace each of the matches with the appropriate parameter.

    Code:

    var mystring:String = "{0} went to {1} on {2}";
    
    function replace(str:String, ...params):String
    {
        var pattern:RegExp = /{\d}/g;
        var ar:Array = str.match(pattern);
    
        var i:uint = 0;
        for(i; i<ar.length; i++)
        {
            str = str.split(ar[i]).join(params[i]);
        }
    
        return str;
    }
    
    trace(replace(mystring, "marty", "work", "friday")); // marty went to work on friday
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have absolutely no knowledge of google docs but i need to investigate something:
I have to do a project in Corba.I have absolutely zero knowledge of corba.Things
I have an absolutely positioned div containing several children, one of which is a
Have you ever seen any of there error messages? -- SQL Server 2000 Could
I'm thinking about starting to develop a plugin for AutoCAD, but I have absolutely
I'll be the first to admit that my overall knowledge of low level programming
I have absolutely no idea what I'm doing wrong right now. I think I'm
So, I have been reading into the whole OAuth stuff the recent days, trying
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.