Sunday, February 26, 2012

Regular Expression Matching.


 Input a string and a pattern having . and * Output: whether the string fully matches the pattern
. match any char, * means matching 0 or more times.
Example:
input "a", "." => match
input "abc", ".*" => match
input "abcd", "a.*d" => match


Code input/output:

Pattern: a.b*d
Text: acbmaxd
Is Exact Match:true


Pattern: .*
Text: acbmaxd
Is Exact Match:true


Pattern: c.*
Text: acbmaxd
Is Exact Match:false


Pattern: a*c.*x*
Text: acbmaxd
Is Exact Match:true


Pattern: a.*d
Text: acbmaxd
Is Exact Match:true


Pattern: .
Text: a
Is Exact Match:true



No comments:

Post a Comment