String Searching

String Searching

You are given two strings. Determine if the second string is a substring of the first (Do NOT use any substring type library function). The second string may contain an asterisk(*) which should be treated as a regular expression i.e. matches zero or more characters. The asterisk can be escaped by a \ char in which case it should be interpreted as a regular ‘*’ character. To summarize: the strings can contain alphabets, numbers, * and \ characters.

NOTE: Do NOT use any substring type library function!

Example 1:


input data:
This is good, is
output:
true

Example 2:


input data:
ZedCoder,Z*der
output:
true

Credits: This is a CodeEval challenge. Test your answer on CodeEval.

Seda
Seda Kunda is a web designer and developer with a degree in Computer Science and a great passion for code. Besides code, she enjoys pepperoni pizza, watching the bachelor and sleeping in on Saturdays.
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn