in reply to String matching idea
Update: no code was requested, so using the spoiler tag:
If your strings only contain "a" and "b", you can use