Code Search for Developers
 
 
  

regex1.cc from AlphaMail at Krugle


Show regex1.cc syntax highlighted

#include <string>
#include <boost/regex.hpp>
#include <iostream>
#include <cstdlib>

using namespace boost;

void dump_matches(smatch &m)
{
   int i;

   for(i=0; i<m.size(); i++) {
      std::cout << "\tmatch[" << i << "] = " << m[i].str() << std::endl;
   }
}

int main()
{
   int i;
   smatch matches;
   regex pattern("^[abc],\\s+\\((today|tomorrow)\\)\\s+[0-9]+.*([/])$", boost::regbase::perl|boost::regbase::icase);
   boost::regex command("^(?:(\\S+)\\s*|\"[^\"]+\"\\s*)+$", boost::regbase::perl);

   std::string s = "B,    (TODAY) 102 this is tone/";
   std::string s2 = "B,    (ToMoRRow) 102 hello word";

   if(regex_match(s, matches, pattern)) {
      dump_matches(matches);
      std::cout << "conversion: " << std::atoi(matches[2].str().c_str()) << std::endl;
   } else
      std::cout << "No match on s" << std::endl;
   if(regex_match(s2, matches, pattern)) {
      dump_matches(matches);
      std::cout << "conversion: " << std::atoi(matches[2].str().c_str()) << std::endl;
   } else
      std::cout << "No match on s2" << std::endl;

   std::string s3 = "B  \"a, b, c, d\" 120 41 inbox";
   if(regex_match(s3, matches, command)) {
      dump_matches(matches);
   } else
      std::cout << "No match on command string" << std::endl;
   return 0;
}




See more files for this project here

AlphaMail

AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.

Project homepage: http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other

  jcorba/
    IMAPClient.java
    IMAPServer.java
    imap.idl
  Makefile
  cache_entry.cc
  client_socket.cc
  date_time.cc
  imaps_test.cc
  map_test.cc
  mkdir.cc
  mm.cc
  oop.cc
  parse_response.cc
  regex1.cc
  request_processor.cc
  server_socket.cc
  split.cc
  ssl.c
  ssl_client.cpp