473,805 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
0 894

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2056
by: Jim G. | last post by:
I am attempting to develop an application for a client that will monitor Web Traffic on a Users PC (from a tray application that the user downloads) - I am NOT interested in blocking or limiting internet access, I only want to be able to monitor (listen) for ANY internet access by the User from their PC and then once that is done to "sniff" the packet of info to determine exactly what webpage the user access. My client is wanting to see...
3
2123
by: Toto | last post by:
Gray Davis is a desperate man. Facing recall, he has just put the safety of California motorists at risk in a naked bid to buy Hispanic votes. Davis signed into law a bill he had twice rejected, to allow illegal aliens to get driver's licenses. One million illegals, many of them young, single males, will soon be on the roads of California. Inevitably, the toll of traffic dead will soar and California families will pay in the lives of...
10
14063
by: eyh5 | last post by:
Hi, My C code (running on Soalris Unix) has some "segmentation fault" that I wish to use purify to do it. I poked around the web, and found some information about adding some lines in a Makefile file to use purify. However, my code is a rather simple single-source C program, and I didn't write a Makefile for it. I'm wondering if anybody can tell me which commands are to be entered at the Unix prompt to use purify. And, I don't know if...
4
3739
by: YeeCN | last post by:
Hi, Can anybody tell me how to play a "beep" sound or any other sound at all in C#? I thought it would be easy but I have been searching up and down.... Thanks a lot. Best regards, Yee
1
2648
by: Dave McCloskey | last post by:
How can I convert the "Enter" key to a "Tab" so my application will act like "Tab" has been hit when the "Enter" key has actually been depressed. This gives type-writer functionality to programs. I was able to do this very simply in VB6, however, I have not found a method to do this in .NET. -- Take Care, Dave
13
2397
by: Morgan Bachu | last post by:
Hello everybody, I have an intranet application which is mostly a bunch of data editing forms. The database has about 20 tables all related together. Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
5
3201
by: comp.lang.php | last post by:
$orderBy = 's.app_date desc, s.last_name asc, s.first_name asc, s.mi asc'; if ($_REQUEST) { $ascArray = array('asc' => 'desc', 'desc' => 'asc'); // ARRAY OF ALL ORDERING POSSIBILITIES $junk = preg_match('/(+)a|sc(,?.*$)/i', $orderBy, $matchArray); $orderBy = substr($orderBy, 0, strpos($orderBy, $matchArray)) . ' ' . $ascArray] . substr($orderBy, strpos($orderBy, $matchArray) +
1
1920
by: D.M. | last post by:
Hi, One of the people here at work has designed a database that students will be using to enter data. She has Yes/No selection buttons, which start out grayed out with no value. If a student selects the Yes or No in error, is there any simple way to allow for the boxes to be unchecked again to "no selection"? Any help will be appreciated. Thanks, Dan M.
25
2888
by: william.hooper | last post by:
here is my form: <html> <head></head> <body> <FORM ACTION="code.php" method="post"> <INPUT TYPE=SUBMIT NAME="arty.jpg" VALUE="Action"> </FORM>
6
1764
by: grbgooglefan | last post by:
I am creating functions, the return result of which I am using to make decisions in combined expressions. In some expressions, I would like to inverse the return result of function. E.g. function contains(source,search) will return true if "search" string is found in source string. I want to make reverse of this by putting it as: if ( ! contains(s1,s2) ): return 1
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10361
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.