Sunday, March 30, 2014

Regular Expression I

Over the last couple weeks, we were working our ass off on the second assignment of the term, which is about the concept of regular expression. According to Wiki, regular expression is a sequence of characters that forms a search pattern, mainly for use in pattern matching with strings, or string matching operations. Our tasks were in two parts, the first one was simply straight. We were asked to write various classes for different combination of regular expressions. The simplest form of a regular expression is a single string of either 'e', '0', '1', '2'. Furthermore, we can add as many of '*' (stars) as we want at any of regular expression to form a new regular expression. Also, we can use '.' or '|' to combine two different valid regular expressions to form a new one. Basically, all we need to do is to write a parent class for the single regular expression, and inherit all the features to create children classes. The reason we can do this is that the regular expressions can be presented in the form of a tree structure. We did not run into any trouble when finishing the first part, but after seeing the second part, we realized it might be a big challenge. 

No comments:

Post a Comment