All strings over a b c that contain exactly two csSolutionab

All strings over {a, b, c} that contain exactly two c’s.

Solution

(?:[ab]*c[ab]*c[ab]*)+?

[ab]*   — String matches the zero or unlimited times, the string look like this (ababab, bababa, aabbaaa, etc).

c[ab]* - String matches the zero or unlimited times with one \"c\", the string look like this (cababa, cbababa, cbbbaaa, etc).

+? Quantifier — Matches between one and unlimited times the string matches. like (ccab, abcc, cabc, ababababcc, cac, abcccc, abcabc, etc.)

All strings over {a, b, c} that contain exactly two c’s.Solution(?:[ab]*c[ab]*c[ab]*)+? [ab]* — String matches the zero or unlimited times, the string look like

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site