<div dir="ltr"><div><div>Thanks Matt and Dirk. Both suggestions are good. I'll try one of them ( not sure which<br></div>yet ) and let you know how it works out. Definitely it's not as as easy a problem as I originally thought. Thanks again.<br></div><div><br></div>                                                                                         Mark<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 13, 2015 at 9:41 AM, Matt D. <span dir="ltr"><<a href="mailto:matdzb@gmail.com" target="_blank">matdzb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 1/13/2015 07:27, Mark Leeds wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi All: I was trying to do something with regular expressions in Rcpp so I piggy backed<br>
heavily off of Dirk's boost.regex example in the Rcpp Gallery where he takes streams of digits and checks them for machine and human readability.<br>
</blockquote></span>
Hi!<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
My problem is actually pretty different and simpler. Essentially, if a character string ends in "rhofixed" or "norhofixed", then that part of the character string should be removed. The R code below illiustrates what I'm trying to do.<br>
<br>
But, when I write the Rcpp code to do the same thing and  set Sys.setenv("PKG_LIBS"="-<u></u>lboost_regex"), I don't get the same result. I don't know if  it's due to the regex engine being different in boost or I could be doing something else wrong. Thanks for any help.<br>
</blockquote></span>
It does indeed seems simpler than an usual use case for regex. Hence, perhaps you can go about it differently:<br>
- use `boost::algorithm::ends_with` (from <boost/algorithm/string/<u></u>predicate.hpp>) to check whether your predicate (i.e., a character string ends in "rhofixed" or "norhofixed") holds<br>
- if so, use the `erase` member function (<a href="http://en.cppreference.com/w/cpp/string/basic_string/substr" target="_blank">http://en.cppreference.com/w/<u></u>cpp/string/basic_string/substr</a><u></u>) to get rid of the substring (note: if one of the aforementioned predicates is satisfied, then you can trivially infer how long is the substring subject to removal -- and can thus use, say, the iterator-pair version, stepping backward from `std::end(your_string)` as needed).<br>
<br>
HTH!<br>
<br>
Best,<br>
<br>
Matt<br>
<br>
</blockquote></div><br></div>