How should I handle the case when the pattern to be matched contains the wildcard character, *
, such as AB*C
, which is present is the text, ABEFGCS
(here *
consumes characters EFG
) using the KMP-Algorithm ?
What modification in the algorithm can solve this problem ?
Actually I got it, leaving answer for reference, we can simply break the string about the wildcard operator, apply KMP on each part, and check whether each part is a sub-string or not, also, whether the parts are contiguous or not can be checked in linear time, hence the overall time complexity is still linear.