Match a basic regular expression · Compiler

Match a basic regular expression

Decide whether the pattern matches the entire text. A lowercase letter matches itself and a dot matches any one letter. A star immediately after a letter or dot allows zero or more occurrences of that atom. A match must consume every text character.

Input
Two space-separated tokens on one line, text then pattern. Use EMPTY for either empty token. Text has 0 to 30 lowercase ASCII letters. The pattern has 0 to 30 characters and consists of lowercase ASCII letters or dots, each optionally followed by one star (*). The dot is written as a period (.).
Output
Print YES for a full match or NO otherwise.

Compiler Explorer runs your code when you run or check it.

Loading your exercise draft…