'undefined' matches in AS3 RegExp? huh?

I've got a long regex in AS3 / Flex which finds one of a couple dozen words. The Regex looks like: word|wordup|wordly|wordster

when I do "wordup wordster!".match(regex) I'm getting undefined maches! the match array that's returned has matches: [0] 'wordup' [1] undefined array length: 2

Is there a known bug in AS3's grouping matches? What could make some words show up in the returned array of matches, and others return as undefind?

I've looked for stray incorrect characters in my regular expression, and inspected the regular expression several times over.

If I just search for 'wordup' then I get a match array length 1, with the correct contents. If I search for just 'wordster' then I get an array length one with matches[0] being undefined again.

------ update -------

After lots of experimenting... my regular expression was just too long for AS3 My actual regular expression used grouping, and had optional parenthesis:

(?:(?(\bword\b))?|(?(\bwordup\b))?| ... and so on for 51 words.

simplifying to: (?:\bword\b|\bwordup\b|

somehow made the match groups work just fine, even though I don't have any parenthesis that would normally be necessary to define groups...


When you're dealing with "mystery" problems, you should always show your actual code, not something you think is equivalent. word|wordup|wordly|wordster won't give you any "undefined" matches.

Instead of using (?:\bword\b|\bword2\b), use this: \b(?:word|word2)\b

The regex word|(word2)?|word3 will give you zero-length matches, because the second alternative in the regex is optional. It will match the zero-length string at every position in the string where "word" cannot be matched.

Need Your Help

Delete an object and all references to it in Python?

python c memory-management swig

Is there a way to remove all references to an object at once? I know that's unpythonic, so I'll explain what I'm trying to do and maybe someone knows a better way.

Integrating Chosen JQuery plugin with Symfony2 SonataAdminBundle

symfony2 symfony-sonata jquery-chosen

I am using SonataAdminBundle version 2.0 with Symfony2 version 2.0.11