The following expression will match strings with even occurences of 'c':
^[^c]*(c[^c]*c[^c]*)*$
ccar(Yes), ccarc (No), cccarc (Yes)...
I would like to edit it to only match the inputs with letters 'c' and 'd' only:
ccddd(Yes), dddddccc (No), cccddcdddd (Yes)...
The number of 'd' can be either even or odd.
Thank you.
CodePudding user response:
If it should only allow d
as the alternative to c
, replace [^c]
with d
.
^d*(cd*cd*)*$