SafeSend interview question

How to match a pattern in a string