#include "validfilter.h"
using namespace boost;
using namespace std;
validfilter::validfilter(void)
{
}
validfilter::~validfilter(void)
{
}
bool validfilter::IsFloatAndNum( std::string value)
{
return validmatch( value,VALIDFILTER_FLOATNUM);
}
bool validfilter::IsFloat( std::string value)
{
return validmatch( value,VALIDFILTER_FLOAT);
}
bool validfilter::IsNum( std::string value)
{
return validmatch( value,VALIDFILTER_NUM);
}
bool validfilter::IsAlphabet( std::string value)
{
return validmatch( value,VALIDFILTER_ALPHABET);
}
bool validfilter::validmatch( std::string& value,std::string regex_expression)
{
if( value.empty() || regex_expression.empty() )
return false;
boost::regex expression(regex_expression);
if( regex_match( value,expression)) //字符串匹配
{
return true;
}
else
{
return false;
}
}
|