Sign in to follow this  
Tradone

difficult time using boost::regex, simple parsing

Recommended Posts

this is impossible. can somebody recommend me an easy link to a quick and dirty guide to boost spirit? edit: originally thought spirit was the solutions to by problem, but found that regex can do the same thing (and regex was much easier) [Edited by - Tradone on March 17, 2006 10:50:26 AM]

Share this post


Link to post
Share on other sites
Isn't Boost.Spirit offical docs enough already? thats probably the reason why information on it is sparse since i believe there docs pretty much cover everything, there should be a quick calculator example around there.

Share this post


Link to post
Share on other sites
wow, they expect me to understand all that technical and that hard to understand manual?
I'm not at that level yet (talking about level, how good do I have to be in C++ to understand that? I just learned about the STL 2 weeks ago), and I've seen the tutorial on code project already and boy I can't understand it in a quick nutshell.

I would like to parse something like this on runtime.


($set cfg.hello=I am a newb)
($set cfg.hello2=cfg.hello)
($cfg.hello2)
($if cfg.hello=cfg.hello2)
($set cfg.hello2=I am a C++ pro)
($else)
nope!
($endif)

($if cfg.hello=cfg.hello2)
nope!
($else)
yippie! I'm a pro now!!
($endif)


output: yippie! I'm a pro now!!


I mean if I have to read the whole thing, I guess I have to.
but if I can do without it, I'd like to just know an easy way around it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tradone
wow, they expect me to understand all that technical and that hard to understand manual?
I'm not at that level yet (talking about level, how good do I have to be in C++ to understand that? I just learned about the STL 2 weeks ago), and I've seen the tutorial on code project already and boy I can't understand it in a quick nutshell.

I would like to parse something like this on runtime.

*** Source Snippet Removed ***
output: yippie! I'm a pro now!!


I mean if I have to read the whole thing, I guess I have to.
but if I can do without it, I'd like to just know an easy way around it.
You should pursue spirit if it interests you, but IMO it's not that easy to get into, especially if you don't already have a strong background in the STL, template programming, and perhaps the boost library in general. It is, as you note, very technical.

You might have an easier time with boost::tokenizer<>, which isn't nearly as powerful as spirit, but has some nice features and is very easy to use.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tradone
wow, they expect me to understand all that technical and that hard to understand manual?
I'm not at that level yet (talking about level, how good do I have to be in C++ to understand that? I just learned about the STL 2 weeks ago), and I've seen the tutorial on code project already and boy I can't understand it in a quick nutshell.

I would like to parse something like this on runtime.

*** Source Snippet Removed ***
output: yippie! I'm a pro now!!


I mean if I have to read the whole thing, I guess I have to.
but if I can do without it, I'd like to just know an easy way around it.


It almost seems as though you're looking for code that you can copy+paste+edit to suit you. The Boost::Spirit documentation is about as simple as I expect you're going to get for a rather complicated parsing library. They don't expect you to understand the entire manual, or even every single feature of the library, but you should definitely read the FAQ, Quick Start, and maybe Quick Reference. Use other sections of the manual to expand upon the ideas presented in those sections if you're still unclear about things.

However, if you want something a bit more simplistic, you could certainly look at Boost::Tokenizer, or possibly Boost::Regex.

Share this post


Link to post
Share on other sites
thank you masters.

Yes, it was difficult to understand.
I guess I should not get into spirit, for now and perhaps just use the tokenizer.

Then I believe I can't parse them on runtime from a file containing the above source code. (Well, once I get better in C++ (god knows when), I can perform the upgrade then)

Boost::Regex vs Boost::Tokenizer

Which do you think is better for my scenario?
and another question, how good do I have to be in order to understand Boost::Spirit?

Share this post


Link to post
Share on other sites
Quote:
Original post by Tradone
Boost::Regex vs Boost::Tokenizer

Which do you think is better for my scenario?
tokenizer<> is about as simple and straightforward as it gets, so if it meets your needs and ease of use is what you're after, I'd go for that. boost::regex is a little more complicated, I think.
Quote:
and another question, how good do I have to be in order to understand Boost::Spirit?
An easy way to find out is to study the documentation and see if you understand it :-) This is just IMHO, but personally I wouldn't try to tackle it unless you're already comfortable with the STL and at least reasonably proficient in template programming techniques.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Quote:
Original post by Tradone
Boost::Regex vs Boost::Tokenizer

Which do you think is better for my scenario?
tokenizer<> is about as simple and straightforward as it gets, so if it meets your needs and ease of use is what you're after, I'd go for that. boost::regex is a little more complicated, I think.
Quote:
and another question, how good do I have to be in order to understand Boost::Spirit?
An easy way to find out is to study the documentation and see if you understand it :-) This is just IMHO, but personally I wouldn't try to tackle it unless you're already comfortable with the STL and at least reasonably proficient in template programming techniques.


I'll take your advice and not tackle it.
I'll come back to it next time when I think I'm up at that level :D
so Regex it is.
reading the first example and just looks like the same thing as string.find() so far...
we'll see...

Share this post


Link to post
Share on other sites
I think the Boost::Regex is powerful enough to parse my application.
Thanks a whole bunch, and I apologize my poor communication skills.

how do I pronounce Regex? lool
Reejects?
Re(as in reggae)gecks ?

edit: after installing the boost library on freebsd through the ports system, I get the following error code from the following source.

/*
*
* Copyright (c) 1998-2002
* John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/


/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE partial_regex_grep.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Search example using partial matches.
*/


#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <boost/regex.hpp>

#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{ using ::memmove; }
#endif

// match some kind of html tag:
boost::regex e("<[^>]*>");
// count how many:
unsigned int tags = 0;
// saved position of partial match:
const char* next_pos = 0;

bool grep_callback(const boost::match_results<const char*>& m)
{
if(m[0].matched == false)
{
// save position and return:
next_pos = m[0].first;
}
else
++tags;
return true;
}

void search(std::istream& is)
{
char buf[4096];
next_pos = buf + sizeof(buf);
bool have_more = true;
while(have_more)
{
// how much do we copy forward from last try:
unsigned leftover = (buf + sizeof(buf)) - next_pos;
// and how much is left to fill:
unsigned size = next_pos - buf;
// copy forward whatever we have left:
std::memmove(buf, next_pos, leftover);
// fill the rest from the stream:
is.read(buf + leftover, size);
unsigned read = is.gcount();
// check to see if we've run out of text:
have_more = read == size;
// reset next_pos:
next_pos = buf + sizeof(buf);
// and then grep:
boost::regex_grep<bool(*)(const boost::cmatch&), const char*>(grep_callback,
static_cast<const char*>(buf),
static_cast<const char*>(buf + read + leftover),
e,
boost::match_default | boost::match_partial);
}
}

int main(int argc, char* argv[])
{
if(argc > 1)
{
for(int i = 1; i < argc; ++i)
{
std::ifstream fs(argv[i]);
if(fs.bad()) continue;
search(fs);
fs.close();
}
}
else
{
std::string one("<META NAME=\"keywords\" CONTENT=\"regex++, regular expressions, regular expression library, C++\">");
std::string what;
while(what.size() < 10000)
{
what.append(one);
what.append(13, ' ');
}
std::stringstream ss;
ss.str(what);
search(ss);
}
std::cout << "total tag count was " << tags << std::endl;
return 0;
}



error:
regex.cpp:24:27: boost/regex.hpp: No such file or directory
regex.cpp:31: error: `boost' has not been declared
regex.cpp:31: error: expected constructor, destructor, or type conversion before "e"
regex.cpp:31: error: expected `,' or `;' before "e"
regex.cpp:37: error: `boost' has not been declared
regex.cpp:37: error: expected `,' or `...' before '<' token
regex.cpp:38: error: ISO C++ forbids declaration of `match_results' with no type
regex.cpp: In function `bool grep_callback(int)':
regex.cpp:39: error: `m' undeclared (first use this function)
regex.cpp:39: error: (Each undeclared identifier is reported only once for each function it appears in.)
regex.cpp: In function `void search(std::istream&)':
regex.cpp:70: error: `boost' has not been declared
regex.cpp:70: error: `regex_grep' undeclared (first use this function)
regex.cpp:70: error: expected primary-expression before "bool"
regex.cpp:70: error: expected `;' before "bool"
regex.cpp:105:2: warning: no newline at end of file
151# whereis boost
boost: /usr/ports/devel/boost
151# find / -name regex.hpp -type f -print
/usr/local/include/boost/algorithm/string/regex.hpp
/usr/local/include/boost/regex/v3/regex.hpp
/usr/local/include/boost/regex/v4/regex.hpp
/usr/local/include/boost/spirit/utility/regex.hpp
/usr/local/include/boost/regex.hpp


okay, as you can see I searched for regex.hpp and I found where it is.
I think I have to change the library path file, but I don't know where the library path files are located.....
please help..

[Edited by - Tradone on March 16, 2006 6:04:30 PM]

Share this post


Link to post
Share on other sites
151# g++ -o regex -L/usr/local/lib -R/usr/local/lib -I/usr/local/include regex.cpp

So this is what I did, and I get a really hard error code..


/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEEC1ES3_S3_RNS_13match_resultsIS3_S6_EERKNS_14reg_expressionIcS8_S9_EENS_15regex_constants12_match_flagsE+0x54): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::perl_matcher(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&, boost::regex_constants::_match_flags)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::get_traits() const'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEEC1ES3_S3_RNS_13match_resultsIS3_S6_EERKNS_14reg_expressionIcS8_S9_EENS_15regex_constants12_match_flagsE+0x8d): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::perl_matcher(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&, boost::regex_constants::_match_flags)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::empty() const'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEE24estimate_max_state_countEPSt26random_access_iterator_tag+0x2a): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::estimate_max_state_count(std::random_access_iterator_tag*)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::size() const'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEE8find_impEv+0xb8): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::find_imp()':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::mark_count() const'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEE8find_impEv+0x1c8): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::find_imp()':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::mark_count() const'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEE8find_impEv+0x241): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::find_imp()':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::mark_count() const'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEE8find_impEv+0x285): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::find_imp()':
: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail15save_state_initD1Ev+0x11): In function `boost::re_detail::save_state_init::~save_state_init()':
: undefined reference to `boost::re_detail::put_mem_block(void*)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail15save_state_initC1EPPNS0_11saved_stateES4_+0x13): In function `boost::re_detail::save_state_init::save_state_init(boost::re_detail::saved_state**, boost::re_detail::saved_state**)':
: undefined reference to `boost::re_detail::get_mem_block()'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost14c_regex_traitsIcE8is_classEcj+0x14): In function `boost::c_regex_traits<char>::is_class(char, unsigned int)':
: undefined reference to `boost::re_detail::c_traits_base::class_map'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost14c_regex_traitsIcE9translateEcb+0x1f): In function `boost::c_regex_traits<char>::translate(char, bool)':
: undefined reference to `boost::re_detail::c_traits_base::lower_case_map'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEESaIcEE5firstERKNS_14reg_expressionIcS3_S4_EE+0xd): In function `boost::re_detail::access_t<char, boost::regex_traits<char>, std::allocator<char> >::first(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::first(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEESaIcEE12restart_typeERKNS_14reg_expressionIcS3_S4_EE+0xd): In function `boost::re_detail::access_t<char, boost::regex_traits<char>, std::allocator<char> >::restart_type(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::restart_type(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEESaIcEE7get_mapERKNS_14reg_expressionIcS3_S4_EE+0xd): In function `^Yboost::re_detail::access_t<char, boost::regex_traits<char>, std::allocator<char> >::get_map(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::get_map(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEESaIcEE9can_startEcPKhh+0x24): In function `boost::re_detail::access_t<char, boost::regex_traits<char>, std::allocator<char> >::can_start(char, unsigned char const*, unsigned char)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::can_start(char, unsigned char const*, unsigned char, boost::re_detail::_narrow_type const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEESaIcEE7get_kmpERKNS_14reg_expressionIcS3_S4_EE+0xd): In function `boost::re_detail::access_t<char, boost::regex_traits<char>, std::allocator<char> >::get_kmp(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::get_kmp(boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEE18unwind_extra_blockEb+0x4b): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::unwind_extra_block(bool)':
: undefined reference to `boost::re_detail::put_mem_block(void*)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail11raise_errorINS_12regex_traitsIcEEEEvRKT_j+0x15): In function `void boost::re_detail::raise_error<boost::regex_traits<char> >(boost::regex_traits<char> const&, unsigned int)':
: undefined reference to `boost::re_detail::c_traits_base::error_string(unsigned int)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail11raise_errorINS_12regex_traitsIcEEEEvRKT_j+0x21): In function `void boost::re_detail::raise_error<boost::regex_traits<char> >(boost::regex_traits<char> const&, unsigned int)':
: undefined reference to `boost::re_detail::raise_regex_exception(std::string const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcEESaIcEEET_S7_S7_PKNS0_11re_set_longERKNS_14reg_expressionIT0_T1_T2_EE+0x41): In function `char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char>, std::allocator<char> >(char const*, char const*, boost::re_detail::re_set_long const*, boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::get_traits() const'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcEESaIcEEET_S7_S7_PKNS0_11re_set_longERKNS_14reg_expressionIT0_T1_T2_EE+0x258): In function `char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char>, std::allocator<char> >(char const*, char const*, boost::re_detail::re_set_long const*, boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)':
: undefined reference to `boost::c_regex_traits<char>::transform(std::string&, std::string const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcEESaIcEEET_S7_S7_PKNS0_11re_set_longERKNS_14reg_expressionIT0_T1_T2_EE+0x343): In function `char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char>, std::allocator<char> >(char const*, char const*, boost::re_detail::re_set_long const*, boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> > const&)':
: undefined reference to `boost::c_regex_traits<char>::transform_primary(std::string&, std::string const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcEESaIcEE12extend_stackEv+0x16): In function `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, std::allocator<char> >::extend_stack()':
: undefined reference to `boost::re_detail::get_mem_block()'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost11basic_regexIcNS_12regex_traitsIcEESaIcEEC1EPKcjRKS3_+0x13): In function `boost::basic_regex<char, boost::regex_traits<char>, std::allocator<char> >::basic_regex(char const*, unsigned int, std::allocator<char> const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::reg_expression(char const*, unsigned int, std::allocator<char> const&)'
/var/tmp//cc7kXB0a.o(.gnu.linkonce.t._ZN5boost11basic_regexIcNS_12regex_traitsIcEESaIcEED1Ev+0xd): In function `boost::basic_regex<char, boost::regex_traits<char>, std::allocator<char> >::~basic_regex()':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, std::allocator<char> >::~reg_expression()'


Share this post


Link to post
Share on other sites
Quote:
Original post by Tradone
regex.cpp:24:27: boost/regex.hpp: No such file or directory


Now, this tells us that it cannot find boost/regex.hpp. This means that the compiler knows nothing about the boost namespace, or anything about the regex library. I'd suggest setting your include paths to make sure that "[path]/boost/regex.hpp" resolves correctly.

Argh, delayed reply, I'd suggest making sure that the boost static libraries are linked in with your program.

Share this post


Link to post
Share on other sites
Quote:
Original post by Run_The_Shadows
I'd suggest making sure that the boost static libraries are linked in with your program.


How can I do this?
well I'm not getting the same error messages anymore..

Share this post


Link to post
Share on other sites
Quote:
Original post by Tradone
Quote:
Original post by Run_The_Shadows
I'd suggest making sure that the boost static libraries are linked in with your program.


How can I do this?
well I'm not getting the same error messages anymore..


I'm afraid I'm not familiar with command-line compilers. Read the G++ documentation and it should tell you. The errors aren't familiar to me, but it seems they're complaining because they can't find the definitions of things that have been declared.

Share this post


Link to post
Share on other sites
Quote:
Original post by Run_The_Shadows
Quote:
Original post by Tradone
Quote:
Original post by Run_The_Shadows
I'd suggest making sure that the boost static libraries are linked in with your program.


How can I do this?
well I'm not getting the same error messages anymore..


I'm afraid I'm not familiar with command-line compilers. Read the G++ documentation and it should tell you. The errors aren't familiar to me, but it seems they're complaining because they can't find the definitions of things that have been declared.


awk, this is really bad.
can i.... just copy and past my whole library inside /usr/local/include inside /usr/include ?? and everything inside /usr/local/lib to /usr/lib

or should I use LD?

I did some surfing online and they told me not to use LD

Share this post


Link to post
Share on other sites
Perl Regular Expression Syntax

In Perl regular expressions, all characters match themselves except for the following special characters:

.[{()\*+?|^$


I realized I want to parse the special characters.
so I tried the following.
boost::regex e("($*)");
and of course I failed because they're special characters.

so I tried to escape them
boost::regex e("\(\$*\)");
and of course i failed once more as a compile time error

and so I tried once more
boost::regex e("\\(\\$*\\)");
successfully compiled but did not recognize as ($*)
...
help..
links will be helpful

edit: went online and tried this
boost::regex e("'(''$'*')'");
and this:
boost::regex e("'($'*')'");
and both failed..


[Edited by - Tradone on March 16, 2006 9:30:10 PM]

Share this post


Link to post
Share on other sites

Escapes

The POSIX standard defines no escape sequences for POSIX-Extended regular expressions, except that:
Any special character preceded by an escape shall match itself.
The effect of any ordinary character being preceded by an escape is undefined.
An escape inside a character class declaration shall match itself: in other words the escape character is not "special" inside a character class declaration; so [\^] will match either a literal '\' or a '^'.


okay, so I did a
boost::regex e("[(]*[)]");
and it seems to match (*)

so I tried this
boost::regex e("[($]*[)]");
and this
boost::regex e("[(][$]*[)]");

but failed to match ($*)
and seems to only pick up (*) still...

Share this post


Link to post
Share on other sites
what does the dot . do?
I haven't seen documentation on the dot yet...
seen examples though..
thanks for the tip, i'm gonna try that right now.

I changed the matchings to this: boost::regex e("[(][$].*[)]");
and this is the file that is being searched...

($asdf)
(fd$dd)($asdfsdggg)
($asdf)
($asdf)
($asdfdd)





and I only get 1 match.
so I'm thinking that it matched (fd$dd)

edit:
boost::regex e("[($].*[)]");
seems to do the same thing
edit2: found out [($] would mean match ( or $

Share this post


Link to post
Share on other sites
okay I just realized regular expressions are not only offered by boost::regex
there's many tutorials online regarding regular expressions in general..

I've read the tutorials on http://www.regular-expressions.info/
and the information is making be doubt that regex can handle things like...


($set cfg.value=1)
($set cfg.value2=2)
($set cfg.value3=3)
($if cfg.value=1)
($if cfg.value2=2)
($if cfg.value3=4)
not executed
($else)
executed
($endif)
($endif)
($endif)


complex if's...

[Edited by - Tradone on March 17, 2006 1:36:24 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this