Regular Expressions not working

Hi, I have this bit of code that I found here:
https://www.youtube.com/watch?v=v_8rdQjOuxw
and at first regex would work, but then when I hit "[]" it wouldn't. Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <string>
#include <regex>

using namespace std;

int main()
{
    string str;
    while(true)
    {
        cin >> str;

        regex e("ab[cd]*");

        bool match = regex_match(str, e);

        cout << (match? "Matched" : "Not Matched") << endl << endl;
    }
    return 0;
}


Can anyone explain to me why it won't? Thank you.
What was the exact input that doesn't give expected result?
Any input from the video. For example typing "ab" into the program should output "matched" but instead it gives me a regex_error statement and crashes the program.
Topic archived. No new replies allowed.