MongoDB Interview Question

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