I need to do two things:

1: make sure the string matches /^[a-zA-Z0-9_]+(?:\.[a-zA-Z0-9_]+)+$/
2: extract all the individual words (not the dots)

I Can't use \w because it doesn't match "_".

At the moment I'm just using String.split(".") after using the regexp to
test validity.

-Josh

On Fri, Oct 3, 2008 at 5:19 PM, mookie298347 <[EMAIL PROTECTED]> wrote:

> Hmm, maybe I am not understanding your needs.
>
> My pattern works on your example of
> "*&%*&^objectA()*&)(*&908objectB,objectC"
>
> The resulting array contains:
> objectA
> 908objectB
> objectC
>
> Which is what I thought you wanted.
>
> Also, the problem in your RE *is* the non-capturing group which is
> consuming your 'objectB.' You can verify this by using a lookahead
> assertion (?=) instead of the noncapture (?:) group.
>
> var patt:RegExp = /([a-zA-Z0-9_]+)(?=\.?(?:[a-zA-Z0-9_]*))/g;
>
> This pattern results in the same output as my simple pattern using
> lookahead assertions.
>
> If these aren't the results you were looking for let me know and I can
> take another look.
>
> HTH
>
> Rob
>
> --- In [email protected], "Josh McDonald" <[EMAIL PROTECTED]> wrote:
> >
> > That will also match "*&%*&^objectA()*&)(*&908objectB,objectC" as
> well which
> > isn't what I'm trying to do.
> >
> > Like I said in the first post, I also tried throwing out the
> non-matching
> > group altogether and simply trying to get
> ["objectA",".objectB",".objectC"]
> > and discarding the dots in the loop (not nice, but better than not
> working
> > at all), and it didn't work. So I don't think the problem is that it's
> > wrapped in a non-matching group.
> >
> > On Fri, Oct 3, 2008 at 11:34 AM, mookie298347 <[EMAIL PROTECTED]> wrote:
> >
> > > 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" <dznuts@> 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 :: josh@
> > > >
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Alternative FAQ location:
> > >
>
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> > > Search Archives:
> > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> > > Links
> > >
> > >
> > >
> > >
> >
> >
> > --
> > "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]
> >
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>


-- 
"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]

Reply via email to