By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,728 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,728 IT Pros & Developers. It's quick & easy.

RegExp: Using groups to solve 1-n / "belongs to"-challenge

P: n/a
Hi!

I hope someone can help me with this challenge, which really bugs me... If
this is the wrong forum, please point me to a better one, as I have not been
able to find a better group for questions about regular expressions.

I have some data which has a structure something like this:

Header 1
- Item 1
- Item 2
- Item 3

Header 2
- Item 4
- Item 5

Header 3
- Item 6
- Item 7
- Item 8
- Item 9

Getting all headers is easy
Getting all items is easy
Getting a list of which items belong to which headers is... less than easy
(for me anyway). ;)

I want to execute a regular expression and get 9 matches like this:

Header 1 - Item 1
Header 1 - Item 2
Header 1 - Item 3
Header 2 - Item 4
Header 2 - Item 5
Header 3 - Item 6
Header 3 - Item 7
Header 3 - Item 8
Header 3 - Item 9

....With the header in group 1 and the item in group 2. Is that possible? If
so, how?

Any help would be greatly appreciated! :)

Thanks in advance

Klaus Jensen,
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.