Adding regex support via boost xpressive

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

@ -6,11 +6,11 @@ prefix=/usr/local
begin : main.o begin.o args.o
$(CC) -o begin $(CCFLAGS) main.o begin.o args.o
main.o: main.cxx begin.o
main.o: main.cxx begin.o
$(CC) $(CFLAGS) main.cxx
begin.o: begin.cxx begin.hpp
$(CC) $(CFLAGS) begin.cxx
$(CC) $(CFLAGS) begin.cxx
args.o: args.cxx args.hpp
$(CC) $(CFLAGS) args.cxx

@ -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
DEPENDENCIES
This program depends on boost/xpressive header only library. On RedHat(-ish) systems do:
yum install boost-devel
before installation
INSTALLATION
git clone git://github.com/mickenordin/begin.git
cd begin

@ -22,16 +22,18 @@
#include <iostream>
#include <string>
#include <boost/xpressive/xpressive.hpp>
using namespace std;
void begin(string needle)
{
string input;
boost::xpressive::sregex regex = boost::xpressive::sregex::compile( needle, boost::xpressive::regex_constants::icase );
while(cin) {
getline(cin, input);
if (input.find(needle) != string::npos) {
if ( boost::xpressive::regex_search(input, regex) ) {
cout << input << endl;
while(cin) {
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 <string>
using namespace std;
void begin(string needle);
string tolower(string str);
#endif

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

Loading…
Cancel
Save