You need to use regex_search , not regex_match :
bool found = regex_search("<html>",regex("h.*l"));
See the IDEONE demo
In simple words, regex_search will search for a substring at any position in a given string. regex_match will return true only if the entire input line matches (the same behavior as matches in Java).
The regex_match documentation says:
Returns whether the target sequence rgx regular expression rgx .
The entire target sequence must match the regular expression for this function> in order to return true (i.e. without any additional characters before or after matching>). For a function that returns true when the match is only part of the sequence> see regex_search .
regex_search is different:
Returns whether any subsequence in the target sequence (subject) rgx regular expression (pattern).
source share