Another regex question
  Home FAQ Contact Sign in
comp.lang.java.help only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.java.help Profile…
 Up
Another regex question         


Author: Knute Johnson
Date: Jul 14, 2008 23:04

Is there a way to get multiple capturing groups without having multiple
sets of parenthesis?

"ABCDEFGHIJKL"

Regex "(\\w{3})" will match 3 letters

"(\\w{3}){4}" will match all four sets of three letters but there will
be only one capturing group.

Is there a way to get multiple capturing groups without doing
"(\\w{3})(\\w{3})(\\w{3})(\\w{3})"?

Thanks,

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
4 Comments
Re: Another regex question         


Author: GArlington
Date: Jul 15, 2008 02:14

On Jul 15, 7:04 am, Knute Johnson rabbitbrush.frazmtn.com>
wrote:
> Is there a way to get multiple capturing groups without having multiple
> sets of parenthesis?
>
> "ABCDEFGHIJKL"
>
> Regex "(\\w{3})" will match 3 letters
>
> "(\\w{3}){4}" will match all four sets of three letters but there will
> be only one capturing group.
>
> Is there a way to get multiple capturing groups without doing
> "(\\w{3})(\\w{3})(\\w{3})(\\w{3})"?
Not AFAIK.
>
> Thanks,
>
> --
> ...
Show full article (0.73Kb)
no comments
Re: Another regex question         


Author: Knute Johnson
Date: Jul 15, 2008 09:05

GArlington wrote:
> On Jul 15, 7:04 am, Knute Johnson rabbitbrush.frazmtn.com>
> wrote:
>> Is there a way to get multiple capturing groups without having multiple
>> sets of parenthesis?
>>
>> "ABCDEFGHIJKL"
>>
>> Regex "(\\w{3})" will match 3 letters
>>
>> "(\\w{3}){4}" will match all four sets of three letters but there will
>> be only one capturing group.
>>
>> Is there a way to get multiple capturing groups without doing
>> "(\\w{3})(\\w{3})(\\w{3})(\\w{3})"?
> Not AFAIK.

Thanks.

--
Show full article (0.74Kb)
no comments
Re: Another regex question         


Author: Daniel Pitts
Date: Jul 15, 2008 17:23

Knute Johnson wrote:
> Is there a way to get multiple capturing groups without having multiple
> sets of parenthesis?
>
> "ABCDEFGHIJKL"
>
> Regex "(\\w{3})" will match 3 letters
>
> "(\\w{3}){4}" will match all four sets of three letters but there will
> be only one capturing group.
>
> Is there a way to get multiple capturing groups without doing
> "(\\w{3})(\\w{3})(\\w{3})(\\w{3})"?
>
> Thanks,
>
Nope. I think you're asking for too much out of regexs. :-)
Show full article (0.69Kb)
no comments
Re: Another regex question         


Author: Knute Johnson
Date: Jul 15, 2008 20:18

Daniel Pitts wrote:
> Knute Johnson wrote:
>> Is there a way to get multiple capturing groups without having
>> multiple sets of parenthesis?
>>
>> "ABCDEFGHIJKL"
>>
>> Regex "(\\w{3})" will match 3 letters
>>
>> "(\\w{3}){4}" will match all four sets of three letters but there will
>> be only one capturing group.
>>
>> Is there a way to get multiple capturing groups without doing
>> "(\\w{3})(\\w{3})(\\w{3})(\\w{3})"?
>>
>> Thanks,
>>
> Nope. I think you're asking for too much out of regexs. :-)
>
> Although, I suspect it would be "somewhat trivial" to add a groupList() ...
Show full article (0.92Kb)
no comments