MongoDB interview question

Design function which performs regex-like operation on a string.