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

  • SEARCH
  • Home
  • 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 8331413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:24:39+00:00 2026-06-09T02:24:39+00:00

I’m using action script and I have an array with more than 400.000 strings

  • 0

I’m using action script and I have an array with more than 400.000 strings and now i’m using a loop and apply a regex to each item of the array to check if it’s valid or not. In case it’s valid, i put such item in a result array.

this process take too long, so it’s a nuisance because all the process must executed many times.

I’ve been thinking about if there is any other way (faster) i could use for applying the regex to all items without using a loop.

Anyone could give me an idea?

EDIT

Here I attach the code used:

            var list:Array;
        var list_total:Array = new Array;
        var pattern:String = '^['+some_letters+']{'+n+'}$';
        var cleanRegExp:RegExp = new RegExp(pattern, 'gi');

        for (var i:int=0; i<_words.length; i++) {
            list = _words[i].match(cleanRegExp);
            if (list != null)
                for (var j:int=0; j < list.length; j++)
                    list_total.push(list[j]);
        }

Thanks.

  • 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-06-09T02:24:42+00:00Added an answer on June 9, 2026 at 2:24 am

    This is not a complete answer, but may help you optimize your code.

    Try to do operations in your loop that are as efficient as possible. Time them using the global getTimer() function so you can compare which methods are the most efficient. When measuring/comparing, you may want to trigger your code many times, so that these differences are noticeable.

    // before test
    var startTime:Number = getTimer();
    // do the expensive operation
    var endTime:Number = getTimer();
    trace("operation took ", endTime - startTime, " milliseconds.");
    

    For example, one improvement is inside a for loop, is to not query the array for it’s length each time:

    for (var i:int = 0; i < myArray.length; i++)
    

    Instead, store the length in a local variable outside of the array and use that:

    var length:int = myArray.length;
    for (var i:int = 0; i < length; i++)
    

    The difference is subtle, but accessing the length from the local variable will be faster than getting it from the Array.

    Another thing you can test is the regular expression itself. Try to come up with alternate expressions, or use alternate functions. I don’t recall the specifics, but in one project we determined (in our case) that using the RegEx.test() method was the fastest way to do a comparison like this. It’s likely that this may be as quick as String.match() — but you won’t know unless you measure these things.

    Grant Skinner has some awesome resources available on his site. They are worth reading. This slide show/presentation on performance is worth looking at. Use the arrow keys to change slides.

    Edit

    Without hearing Grant’s presentation, the initial slides may not seem that interesting. However, it does get very interesting (with concrete code examples) around slide #43: http://gskinner.com/talks/quick/#43

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.