I'm trying to write some c++ code that tests if a string is in a particular format. In this program there is a height followed by some decimal numbers: for example "height 123.45" or "height 12" would return true but "SomeOtherString 123.45" would return false.
My first attempt at this was to write the following:
string action;
cin >> action;
boost::regex EXPR( "^height \\d*(\\.\\d{1,2})?$/" ) ;//height format regex
bool height_format_matches = boost::regex_match( action, EXPR ) ;
if(height_format_matches==true){
\\do some stuff
}
However height_format_matches never seemed to be true. Any help is greatly appreciated!