Adding regex support via boost xpressive

master
Micke Nordin 13 years ago
parent 1b38333f7c
commit 2ef88b0c0f

@ -2,6 +2,13 @@ This is a free implementation of the Cisco ios/asa/catalyst output modifier "beg
http://www.cisco.com/en/US/docs/ios/preface/usingios.html#wp1012384 http://www.cisco.com/en/US/docs/ios/preface/usingios.html#wp1012384
DEPENDENCIES
This program depends on boost/xpressive header only library. On RedHat(-ish) systems do:
yum install boost-devel
before installation
INSTALLATION INSTALLATION
git clone git://github.com/mickenordin/begin.git git clone git://github.com/mickenordin/begin.git
cd begin cd begin

@ -22,16 +22,18 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <boost/xpressive/xpressive.hpp>
using namespace std; using namespace std;
void begin(string needle) void begin(string needle)
{ {
string input; string input;
boost::xpressive::sregex regex = boost::xpressive::sregex::compile( needle, boost::xpressive::regex_constants::icase );
while(cin) { while(cin) {
getline(cin, input); getline(cin, input);
if (input.find(needle) != string::npos) { if ( boost::xpressive::regex_search(input, regex) ) {
cout << input << endl; cout << input << endl;
while(cin) { while(cin) {
getline(cin,input); getline(cin,input);
@ -42,10 +44,4 @@ void begin(string needle)
} }
string tolower(string str) {
for( unsigned int i = 0; i < str.length(); i++) {
str[i] = tolower(str[i]);
}
return str;
}

@ -23,9 +23,9 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
using namespace std; using namespace std;
void begin(string needle); void begin(string needle);
string tolower(string str);
#endif #endif

@ -29,8 +29,6 @@ int main(int argc, char **argv)
{ {
args myargs(argc, argv); args myargs(argc, argv);
myargs.print();
if( argc == 2) { if( argc == 2) {
begin(argv[1]); begin(argv[1]);
} }

Loading…
Cancel
Save