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 696205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:02:21+00:00 2026-05-14T03:02:21+00:00

I need some help about RegExp in AS3. I have a simple pattern :

  • 0

I need some help about RegExp in AS3.

I have a simple pattern :

patternYouTube = new RegExp ( "v(?:\/|=)([A-Z0-9_-]+)", "gi" );

This pattern is looking for the youTube id video.

For example :

var tmpUrl : String;    
var result : Object;
var toto : Array = new Array();
toto = ["http://www.youtube.com/v/J-vCxmjCm-8&autoplay=1", "http://www.youtube.com/v/xFTRnE1WBmU&autoplay=1"];
var i : uint;

for ( i = 0 ; i < toto.length ; i++)
{
     tmpUrl = toto[i];
     result = patternYouTube.exec ( tmpUrl );
     if ( result.length != 0 && result != null )
     {
         trace(result);
     }
}

When i == 0, it works perfectly.
Flash returns me : v/J-vCxmjCm-8,J-vCxmjCm-8

When i == 1, it fails.
Flash returns me : null

When I revert the two strings in my array such as :

toto = [ http://www.youtube.com/v/xFTRnE1WBmU&autoplay=1, http://www.youtube.com/v/J-vCxmjCm-8&autoplay=1 ];

When i == 0, it works perfectly :
Flash returns me : xFTRnE1WBmU

When i == 1, it fails :
Flash returns me : null

Do you have any idea about the problem in the loop ?

  • 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-14T03:02:22+00:00Added an answer on May 14, 2026 at 3:02 am

    That’s what g​lobal RegExps do in JavaScript/ActionScript. You exec them once, you get the first match, exec them again and get the second match. With a g RegExp you have to keep calling it again until you’ve got through all the matches. Then you’ll get null and the search will reset to the start of the string.

    It’s a weird interface, but that’s what we’re stuck with. If you don’t want this behaviour, omit the 'g' flag from the new RegExp constructor. Then you’ll get only the first match, every time.

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

Sidebar

Related Questions

need ask you about some help. I have web app running in Net 2.0.
I am new to all the anonymous features and need some help. I have
I'm pretty new to arrays still. I need some help - I have some
I need some help from the shell-script gurus out there. I have a .txt
Hi I need some help with the following scenario in php. I have a
I'm working with jQuery for the first time and need some help. I have
I am new to php and am asking for some coding help. I have
Ok need some help, I have a system I'm creating that will allow users
I'm new to rails and need some help with iterating through a sql result.
I need some help regarding algorithm for randomness. So Problem is. There are 50

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.