473,378 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

problem with boost::regex compilation

Hello,

did anyone of You have problems using boost::regex ?

That code below :

#include "boost/regex.hpp" /*1*/
int main() /*2*/
{ /*3*/
boost::regex reg("*"); /*4*/
return 0; /*5*/
} /*6*/

isn't working on my Dev-CPP & gcc compilers :/

boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char>
::assign(char const*, char const*, unsigned int)]+0x22):main.cpp: undefined
reference to `boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char >::do_assign(char const*, char const*,
unsigned
int)'
collect2: ld returned 1 exit status

...ane weird is that
1) libraries such as pool, lexical_cast itp. work well
2) after commenting line /*4*/ program compile succesfully

have anyone any suggestions ?

Kamil 'neino'
Jan 2 '08 #1
3 2588
ne***@wp.pl wrote:
did anyone of You have problems using boost::regex ?
only from an aesthetically POV ;-)
That code below :

#include "boost/regex.hpp" /*1*/
int main() /*2*/
{ /*3*/
boost::regex reg("*"); /*4*/
return 0; /*5*/
} /*6*/

isn't working on my Dev-CPP & gcc compilers :/
DEV-Cpp in its newest incarnation contains
gcc 3.4.3, I'd rather not expect the boost
to work on that properly (maybe there is a
port I don't know of).

Under gcc 4.1.2, your snippet (neino.cxx) works fine:

$ gcc -o neino neino.cxx -lboost_regex

and without warnings.
Regards

M.
Jan 2 '08 #2
do You have boost in 1.33 version ?
Jan 3 '08 #3
ne***@wp.pl wrote:
do You have boost in 1.33 version ?
Yes, it is 1.33
BTW.: I tested it on some topics
and would say it's /somehow/ usable -
if[f] raw-strings will be in the
language.

In the frame of a current project, I tried to read
cartesian coordinates and their molecule descriptors
from a simple text file ((just for fun - to test
boost::regex):

[sample text file]
...
36.01645 33.35185 214.75779 OXYGEN 1518 1
36.98106 32.87680 214.22500 CARBON 1518 1
37.78489 32.48092 213.78100 CARBON 1518 1
...
[100_000's of lines to follow]

After the file has been slurped into a std::string,
the following snippet will extract the above data:

...
std::string::const_iterator start, end; // iterators on the buffer
start = file.str().begin(), end = file.str().end();

match_flag_type flags = match_default; // match_continuous;

regex atm("^"
" [\\t\\ ]* ([\\d.]+) [\\t\\ ]+ ([\\d.]+) [\\t\\ ]+ ([\\d.]+) "
" [\\t\\ ]+ ([\\w.]+) "
" [\\t\\ ]* (\\d*) [\\t\\ ]* (\\d*) "
"$",
regex::mod_x);

// - - - - - now read all atoms from string buffer - - - - - //
smatch coord;

while( regex_search(start, end, coord, atm) ) {
std::cout << coord[1] << '\t' << coord[2] << '\t' << coord[3] << '\t'
<< coord[4] << '\t'
<< coord[5] << '\t' << coord[6] << '\t' << std::endl;
// update search position:
start += coord[0].length()+1; // important: advance behind current match
flags |= match_prev_avail; // update flags
}
...
This may look awkward for now, but after seeing the /raw string/
in C++, this might be quite usable ...
Regards

M.
Jan 3 '08 #4

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

Similar topics

2
by: Richard Latter | last post by:
Hello All, I am a newbie to the Boost library and I have a question about a simple function. All I would like to do is to create a simple function that can test strings using regular...
5
by: FBergemann | last post by:
I use SunOS 5.8, gcc 3.3.2, boost 1.33.1. I have build the entire boost package and try to compile a simple example: #include <iostream> #include <string> #include <boost/regex.hpp //...
0
by: amrnablus | last post by:
hello everyone, i'm trying to do something weird in boost regex, i need to get characters "repeated times backreference" !! i.e "3 abc" , "10 abcdefghij" .... any ideas ? ps: i tried {\\2} but...
3
by: MCH | last post by:
hi there, I am working with a HTML-like text with boost:regex. For example, the following pattern might occur in my text <abc efg> <p>EFG</p 12<3> In this case, I would like to extract...
1
by: Barry | last post by:
I used Boost.Xpressive after 1.3.4, and found it interesting and helpful, but I suffer from long complie-time. So I wonder there is a way to write the regular expression in Xpressive and use it in...
13
by: brad | last post by:
Still learning C++. I'm writing some regex using boost. It works great. Only thing is... this code seems slow to me compared to equivelent Perl and Python. I'm sure I'm doing something incorrect....
2
by: brad | last post by:
Try the boost mailing list. They may help you. http://www.boost.org/community/groups.html#users
0
by: mark | last post by:
This is something I came across today that might be of interest to others: including boost/regex.hpp causes the functions in regex.h to have corrupt pmatch subexpression match values. I'm not...
3
by: rottmanj | last post by:
In my application I get a string from my datasource that I need to replace some of the bad chars in the strings. Right now I have written a pretty standard regex that should replace any of the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.