views:

40

answers:

2

Given a string like, "xyz A.B.C.(anything)" (there's at least one space/tab/newline between z and A.)

I'd like to find "A.B.C".

+1  A: 

You probably need to be more specific about what it is you are trying to match exactly.

If it's just letters with a dot followed by them (no whitespace between them), then this will work:

/xyz\s+((?:[A-Z]\.)+)/

(It will put them in the first back reference (i.e. $1).

Senseful
+1  A: 

Something like this:

^\w+\s+((?:[A-Z]\.)+).*$

Gives the following matches (as seen on rubular.com):

matched input        -> group 1 capture
---------------------------------------
xyz A.B.C.whatever   -> A.B.C.
blahblah X.Y.bloop   -> X.Y.

If this is not what you want, then go back and forth with me on rubular and we'll develop the pattern together.

polygenelubricants
@polygenelubricants, eagle,Thank you guys, both work, at least in my situation. I forgot to put (?:
Paul