boost::regexのmatch

正規表現
http://freepg.fc2web.com/cpp/topic_boost_regex_001.html


regex_match.cpp

#include <iostream>
#include <boost/regex.hpp>
#include <string>
using namespace std;
using namespace boost;

int main(int argc, char* argv[]){
  string str = "asdftesthogehoge";
  regex reg(".*t.st.*");
  
  if(regex_match(str, reg)){
    cout << "match" << endl;
  }
  else{
    cout << "not match" << endl;
  }
  return 0;
  
}


なるべく短く使いたい

regex_match("testasdf", regex("t.st.*"));


Makefile

SRC = regex_match.cpp
DST = regex_match

prefix=/opt/local
INCPATH=/opt/local/include
LIBPATH=/opt/local/lib

CC=g++ -O

INCLUDE=-I$(INCPATH)/boost
LIB=$(LIBPATH)/libboost_regex-mt.a

all:
        $(CC) $(SRC)  -o $(DST) $(INCLUDE) $(LIB)