Sunday, February 1, 2015

Regular expression implementation for '*' and '?' wildcard characters

Assuming we have two string - a normal string which will be matched against a regular expression string. The idea is simple: iterate through both string simultaneously. If:

  • current char in regex is '?', skip current characters from both strings
  • current char in regex is '*', find the next matching character in original string
  • else match the current character.

The implementation of the above idea is captured in code at the link

No comments:

Post a Comment