Easy to use regex in C++
cxxtools regex
cxxtools contains a nice class that allows you to use regular expressions in C++. Since it is so handy and not very documented, i like to show an short example.
#include <string> #include <cxxtools/regex.h> bool TwoFour (const std::string& word) { cxxtools::Regex checkTwoFour("^[aA-zZ]{2,4}$"); return checkTwoFour.match(word); }
The function will return true only if word is between 2 and 4 characters long and consist only of alphabetic characters. Of course you can use more compley regular expression.