473,473 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2596
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...
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...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.