I am creating a program which searches for particular types of strings. The alphabet of these strings are in $\{a, b, c\}$, for which every sub string of length 3 contains exactly $c$. Some strings that follow these constraints are:
$cabcbbca$, $cbb$ and $acaacb$
And strings that don't follow the constraints are:
$aaac$, $ccc$ and $cbcaac$
From this, I can see that a regular expression might need to be made to search for strings that follow the constraints.
I have tried hard coding some regular expressions such as:
$((a \cup b)(a \cup b)c)^*$, which would cover strings like $abcabcabc$, but will obviously not work for all strings, as their are many combinations the strings could be in.
I'm not sure how I could create a general regular expression that could strictly follow any sub string of length 3 to contain exactly one $c$. Any help would be appreciated.
cc
are valid.accc
would fail because ofccc
, which is a sub string of length 3 that contains more than onec
. All sub strings of length 3 can only contain onec
. $\endgroup$c
, i.e. are strings such asabab
andabbb
allowed? $\endgroup$