Hi Josh,
Your match is skipping over objectB because it is being "consumed"
(and not captured) by this part of your regular expression:
(?:\.([a-zA-Z0-9_]+))+
If you simply want to match all word characters between dots you can
simply do:
var str:String = 'objectA.objectB.objectC';
var patt:RegExp = /\w+/g;
var matches:Object = str.match(patt);
trace(ObjectUtil.toString(matches));
This captures all consecutive word character groups in the string.
HTH
Cheers,
Rob
--- In [email protected], "Josh McDonald" <[EMAIL PROTECTED]> wrote:
>
> Hey guys,
>
> I'm trying to turn this "objectA.objectB.objectC" into ["objectA",
> "objectB", "objectC"] using a regex, but all I seem to get using
> String.match() is ["objectA", "objectC"]. Can anybody tell me what's
wrong
> with the following?
>
> const multiLevelReferencePattern : RegExp =
> /([a-zA-Z0-9_]+)(?:\.([a-zA-Z0-9_]+))+/;
>
> I also tried to match into ["objectA", ".objectB", ".objectC"] by
throwing
> out the non-matching group and rolling the "\." into the last matching
> group, but I still get the same result (only the last match comes
through).
>
> For now I've switched to a simpler regex in order to RegExp.test() the
> string and then using String.explode(), but I would like to do both
at once
> using String.match() if possible.
>
> Cheers,
> -Josh
>
> --
> "Therefore, send not to know For whom the bell tolls. It tolls for
thee."
>
> http://flex.joshmcdonald.info/
>
> :: Josh 'G-Funk' McDonald
> :: 0437 221 380 :: [EMAIL PROTECTED]
>