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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:08:06+00:00 2026-05-27T17:08:06+00:00

I have the following code (AS3 & CS 5.5): var regEx:RegExp = new RegExp(/(?:^|\s)(\#[^\s$]+)/g);

  • 0

I have the following code (AS3 & CS 5.5):

var regEx:RegExp = new RegExp(/(?:^|\s)(\#[^\s$]+)/g);
var txt:String = "This #asd is a test tweet #hash1 test #hash2 test";

var matches:Object = regEx.exec(txt);
trace(matches);

The trace returns ‘#asd,#asd’. I really don’t understand why it would to this, as in my RegEx testing application ‘RegExhibit’ it returns ‘#asd,#hash1,#hash2’, which is what I’d expect. Can anyone shed any light on this please?

Thanks in advance!

  • 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-27T17:08:07+00:00Added an answer on May 27, 2026 at 5:08 pm

    If you are using .exec, you should run it multiple times to get all results:

    In the following example, the g (global) flag is set in the regular expression, so you can use exec() repeatedly to find multiple matches:

    var myPattern:RegExp = /(\w*)sh(\w*)/ig;  
    var str:String = "She sells seashells by the seashore";
    var result:Object = myPattern.exec(str);
    
    while (result != null) {
        trace (result.index, "\t", result);
        result = myPattern.exec(str);
    }
    

    Source: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/RegExp.html

    A better alternative is probably to use String.match:

    If pattern is a regular expression, in order to return an array with more than one matching substring, the g (global) flag must be set in the regular expression

    An example should be (not tested):

    var regEx:RegExp = /(?:^|\s)(\#[^\s$]+)/g;
    var txt:String = "This #asd is a test tweet #hash1 test #hash2 test";
    
    var matches:Object = txt.match(regEx);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in AS3: var str:String = '<TEXTFORMAT LEADING=2><P ALIGN=LEFT><FONT FACE=Arial
I have following code var res = from c in model.Data select new object[]
I am using following code in as3: var Request:URLRequest = new URLRequest(); var xmlMain:XML=new
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have following code in C# PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
I have following code in C# PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
I have the following regex which suppose to match email addresses: [a-z0-9!#$%&'*+\\-/=?^_`{|}~][a-z0-9!#$%&'*+\\-/=?^_`{|}~.]{0,63}@[a-z0-9][a-z0-9\\-]*[a-z0-9](\\.[a-z0-9][a-z0-9\\-]*[a-z0-9])+$. I have
I have the following AS3 code which converts a bunch of BitMap screenshots to
I have the following code var playingStream:NetStream; function playBytes(bytes:ByteArray): void { var connect_nc:NetConnection =
I have a problem with the following Flash AS3-code: When I change Delete1 to

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.