You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by "Daniel F. Savarese" <df...@savarese.org> on 2001/08/17 00:40:04 UTC

Re: Reg Exp Match

In message <F2...@hotmail.com>, "John Goalby" writes:
>Input string : HEADERAABBCCDD
>Output : AA, BB, CC, DD
>
>I have tried a numbe of things but cannot get it:
>
>HEADER(.{2})*
>
>This ONLY gives me DD.
>
>Any way to get the groups for AA, BB, CC and DD?

Capturing parentheses will only save the last thing they matched which
is why you only get DD.  There are certain things you need to supplement
with program logic.  You will have to iterate and look for each match in
turn unless you know you have a fixed number of character pairs, in which
case HEADER(..)(..)(..)(..) will do, unless what you really want is
HEADER((.)\2)((.)\4)((.)\6)((.)\8)
(The difference being that the first expression will match HEADER123456 while
the second expression won't, but will match HEADER11223344)

daniel