I want a C ++ regular expression that matches “bananas” or “pajamas” but not “bananas2” or “banapaspayamasam” or “bananas” or nothing at all other than these two exact words. So I did this:
#include <regex> int main(int argc, char** argv) { static const std::regex bp = std::regex("\bbananas\b|\bpajamas\b"); printf("%d\n", std::regex_match("bananas", bp)); }
Except that it printed 0! What gives? /\bbananas\b|\bpajamas\b/.test('bananas') gives me true in Javascript, so what is different from C ++?
source share