473,804 Members | 3,602 Online
Bytes | Software Development & Data Engineering Community
+ 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_re gex<char, boost::regex_tr aits<char,
boost::cpp_rege x_traits<char>
::assign(char const*, char const*, unsigned int)]+0x22):main.cpp : undefined
reference to `boost::basic_r egex<char, boost::regex_tr aits<char,
boost::cpp_rege x_traits<char >::do_assign(ch ar 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 2618
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::co nst_iterator start, end; // iterators on the buffer
start = file.str().begi n(), end = file.str().end( );

match_flag_type flags = match_default; // match_continuou s;

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(st art, 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_avai l; // 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
3710
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 expressions. I've written this function which appears to work on the first pass and then fails on the second with the following message. Unhandle exeption in Credit Card Example.exe (KERNEL32.DLL) 0x(Some address): Microsoft C++ Exception.
5
7193
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 // Boost.Regex lib using namespace std;
0
1165
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 it did not work !! :(
3
2812
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 everything between and replace with <pre>, with </pre>. Meanwhile, everything outside should be unchaged except that < is
1
2862
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 Boost.RegEx, since there grammer is simmilar to use
13
4536
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. Any tips? #include <boost/regex.hpp> #include <iostream> // g++ numbers.cpp -o numbers -I/usr/local/include/boost-1_35 /usr/local/lib/libboost_regex-gcc41-mt-s.a // g++ numbers.cpp -o numbers.exe
2
2213
by: brad | last post by:
Try the boost mailing list. They may help you. http://www.boost.org/community/groups.html#users
0
2406
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 sure why. -mark
3
4542
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 bad chars in the strings. However, instead of removing the bad chars it removes all chars from the string. The bad chars I am trying to replace are /'() Here is the current code that I am testing with. boost::regex const...
0
9576
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
10567
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...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6847
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
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...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
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
2983
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.