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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:42:09+00:00 2026-06-07T11:42:09+00:00

Why do match and split produce different results? This is in Actionscript 3.0, but

  • 0

Why do match and split produce different results? This is in Actionscript 3.0, but if this is also true outside of AS3, I would like to know why for that as well.

Example:

var txt:String = "somethingorother";
var re:RegExp = /(\w{2,2})/g;
trace("\t txt.split = " + txt.split(re) + " -- " + txt.split(re).length);
trace("\t txt.match = " + txt.match(re) + " -- " + txt.match(re).length);

Results:

txt.split = ,so,,me,,th,,in,,go,,ro,,th,,er, -- 17
txt.match = so,me,th,in,go,ro,th,er -- 8

Edit:

With the conditions given, I expect the results to be an identical array (with the exception, in this case, of match not finding a final entry for odd-length Strings). Why is there the extra entries in the split? What is split finding that match is getting “correct”?

  • 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-07T11:42:11+00:00Added an answer on June 7, 2026 at 11:42 am

    split splits a string by another string or by a regular expression, keeping any parenthesized groups if the argument is the latter case, which is the behavior you are seeing currently. It is not intended to have the same functionality as match at all, which is used to retrieve one or many matches of a regular expression on a string.


    split will split a string by your regular expression, and keep the parenthesized groups – as separate entries. Therefore, when splitting, the matches are kept separate from the string between them, which is empty – hence your result.

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

Sidebar

Related Questions

Given something like: message.split(/\n.* at.* XXXXXXXX wrote:.*/m).first This works if there is a match,
I am trying to write a regular expression to match and split a custom
I'm trying to match the username with a regex. Please don't suggest a split.
match.matches() returns false. This is odd, because if I take this regex and test
I'm trying to match a string against a pattern, but there's one thing I
9.jul. 3 dni od 205,00 EUR Is it possible with single regex (match opr split)
I've looked for this question on stackoverflow, but didn't found a really good answer
How would you split Regex subexpression matches in to multi-dimensional string arrays? I have
Is there a way in regex's to match a string that is arbitrarily split
I want to split ByteString to words like so: import qualified Data.ByteString as BS

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.