/** * file:test_regex.cxx * @UTF-8N CR+LF * @UTF-8N */ #define STRICT #include <iostream> #include <string> #include <boost/regex.hpp> using std::cout; using std::endl; using std::string; using boost::regex; using boost::regex_match; void test_regex() { string str("Yanch's Programming Memo."); regex reg("Yanch.+Memo\\."); if (regex_match(str, reg)) { cout << "===> Matched." << endl; } else { cout << "===> Not matched." << endl; } } int main(int argc, char *argv[]) { test_regex(); return 0; } |
CXX = g++ CXXFLAGS = -finput-charset=UTF-8 -fexec-charset=UTF-8 -g3 -O0 -Wall DEFS = -DUNICODE -D_UNICODE ECHO = echo INCLUDES = -I"$(BOOST_ROOT)/include" LDFLAGS = LIBS = $(BOOST_ROOT)/lib/libboost_regex-mgw34-mt.lib RM = rm TARGET = test_regex.exe OBJS = test_regex.o all : $(TARGET) $(TARGET) : $(OBJS) $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS) test_regex.o : test_regex.cxx $(CXX) -o $@ -c $< $(CXXFLAGS) $(INCLUDES) $(DEFS) clean : -$(RM) $(OBJS) $(TARGET) |
~test_regex_cxx>test_regex.exe ===> Matched. |