We have a string input and the following combinations are valid (e.g. sunday, *sunday*, sun*day*, *sun*day, su*nda*y)
If it contains only a single asterisk, then it is a bad input.
So given the above input, how do I check to see if the string contains multiple asterisks.
You could use
String.matcheswith a regular expression:If you want exactly two asterisks:
Though for this task it might be simpler just to iterate over the string and count the asterisks.