Σ = {a, b}

Write a Regular Expression, that only accepts strings with exactly two or three a’s in the string. There is no restriction on occurrence of b’s in the string.

Few examples of accepted strings are as under;
- bbaabbbba
- baba
- aba
- abaa
- aa
- aaa
etc.

So what do you have so far? Do you know how to use a string? The find_first_not_of() function can be really helpful.

Are you supposed to be writing code to perform the operation, or are you just supposed to be writing a regular expression, or are you supposed to be writing code containing a regular expression which then calls some kind of library function that processes regular expressions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.