RegEx Capturing 
Author Message
 RegEx Capturing

Hi,

I have a regex that looks somewhat like this:

(?<foobar>\s(?<foo>\w+)\s(?<bar>[0-9]+)\s)+   'Simplified

What I'd like to do is for each 'foobar', get the nested 'foo' and
'bar'.  But using Match.Groups() I get all foobars, or all foos or all
bars - I lose the association.   I'd like to access them in a
hierarchical way.  Is that possible? Or do I just need run seperate
sub- regexs/matches?

Thanks.



Sat, 03 Dec 2005 09:19:44 GMT  
 RegEx Capturing
Ricky,

Try running this:
((foo)(bar))

The first group will pick up all foobar instances while the nested groups
will pickup the foo and bar within.


Quote:
> Hi,

> I have a regex that looks somewhat like this:

> (?<foobar>\s(?<foo>\w+)\s(?<bar>[0-9]+)\s)+   'Simplified

> What I'd like to do is for each 'foobar', get the nested 'foo' and
> 'bar'.  But using Match.Groups() I get all foobars, or all foos or all
> bars - I lose the association.   I'd like to access them in a
> hierarchical way.  Is that possible? Or do I just need run seperate
> sub- regexs/matches?

> Thanks.



Sat, 03 Dec 2005 09:51:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. RegEx to capture script blocks?

2. Capture Buffer Quits Capturing (DirectSound)

3. How to Capture the Screen and capture and poke keypresses

4. RegEx - sorry to bother - found the solution

5. RegEx - my personal illogical nightmare

6. Using Regex to get a block of text

7. How to split URL without http:// using RegEx?

8. Help with Regex.Replace pls...

9. RegEx Count

10. More RegEx III

11. More RegEx (Numbers with Commas)

12. RegEx

 

 
Powered by phpBB® Forum Software