Pergunta de entrevista da empresa Meta
Write the actual code to parse a regular expression including "*", which stands for 0 or more characters, "+", which stands for 1 or more characters, and ".", which stands for 1 exact character.
Respostas da entrevista
Here's my solution
http://ideone.com/qkY4D
It switches any x+ with xx* and doesn't allow 2 consecutive wildcards (+ or *) and doesn't allow a single wildcard as a pattern.
@Redeye that won't work. Consider "abbbbcd" and "a*bcd".
My solution: http://ideone.com/1q0wt
It assumes "clean" matcher string where the wildcard characters */+ do no appear consecutively. You can preprocess the matcher string to remove those (***** => *, *+ => + etc)
@Godfrey
Your code is wrong.. It would return true on the pattern "dc+" and the string "dccccqz"
Use two pointers for regex and string to be matched.
Move pointer in regex as per conditions of *,+ or . untill you find next character
After traversing trhough regex using these pointers, if characters finish early or still there are characters after regex, it is a mismatch.