$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: tweety (mitea_at_[hidden])
Date: 2004-08-01 22:03:54
Why don't you use something like
^
Point\(\d+\)\s*=\s*\{\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\.\d+)?\s*}\s*;
|
Line\(\d+\)\s*=\s*\{\s*\d+\s*,\s*\d+\s*}\s*;
[...add whatever you need here...]
$
And run that for each line. Then you can use the matched method of the match
class to see if a group matched (oh, and set the groups you're interested
for).
----------------------------------
Peace and love,
Tweety
mitea_at_[hidden] - tweety_04_01_at_[hidden]
YahooID: tweety_04_01
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] 
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of hackervalley
> Sent: August 1, 2004 7:36 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] [Help on implementation of boost regex]
> 
> Hello,
> 
> I try to use boost regex . I don't have a lot of experience of using
> boost regex . Boost regex examples aren't so explicit for me. 
> So I need
> some help to parse this example file.
> 
> Point(1) = {0,0,0,0.1};
> Point(2) = {1,0,0,0.1};
> Point(3) = {0,1,0,0.1};
> Point(4) = {1,1,0,0.1};
> Line(1) = {1,2};
> Line(2) = {2,4};
> Line(3) = {4,3};
> Line(4) = {3,1};
> Line Loop(5) = {2,3,4,1};
> Plane Surface(6) = {5};
> 
> I can't read each informations to use it after.
> I can't match for use IdentificationNumber of 
> Point(IdentificationNumber).
> Actually my code look so :
> 
>    /*
> g++ -Wall -O2 -o ifstream ifstream.cc
> */
> 
> #include <iostream>
> #include <fstream>
> #include <string>
> 
> /* boost regex header */
> #include <boost/regex.hpp>
> 
> using namespace std;
> using namespace boost;
> 
> int
> main (int argc, char argv[])
> {
> 	char buffer[256];
> 	string filename;
> 	string inputstring;
> 
> 	cout << "Input filename ";
> 	cin >> filename;
> 	ifstream readfile (filename.c_str (), ios::in);
> 
> 	if (!readfile.is_open ())
> 	{
> 		cout << "Error opening file" << endl;
> 		return 0;
> 	}
> 
> 	regex exPoint ("Point");
> 	regex exLine ("Line");
> 	regex IdentificationNumber ("[:digit:]");
> 	
> 	while (!readfile.eof ())
> 	{
> 		readfile.getline (buffer, 200);
> 		inputstring = buffer;
> 
> 		if (regex_search (inputstring, exPoint))
> 		{
> 			cout << "Point" << endl;
> 			smatch result;
> 			if (regex_search
> 			    (inputstring, result, IdentificationNumber))
> 			{
> 				cout << "Identification Number 
> " << result << endl;
> 				}
> 			else
> 				cout << "Error regex_match" << endl;
> 		}
> 		if (regex_search (inputstring, exLine))
> 		{
> 			cout << "Line" << endl;
> 		}
> 		cout << buffer << endl;
> 	}
> 
> 	readfile.close ();
> 
> 	return (0);
> }
> 
> 
> Thank you for help. Best regards
> 
> hackervalley
> http://hackervalley.free.fr
> 
> 
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://listarchives.boost.org/mailman/listinfo.cgi/boost-users
>