Welcome to another sample coding interview test to prep you for that coveted job with the biggest tech companies in the world. Today we will be looking at regular expressions. As always, write your answer in a github gist or pastebin and share the link in the comments below.
Implement regular expression matching with the following special characters:
.(period) which matches any single character
*(asterisk) which matches zero or more of the preceding element
That is, implement a function that takes in a string and a valid regular expression and returns whether or not the string matches the regular expression.
For example, given the regular expression “ra.” and the string “ray”, your function should return true. The same regular expression on the string “raymond” should return false.
Given the regular expression “.*at” and the string “chat”, your function should return true. The same regular expression on the string “chats” should return false.