Carl Nolan’s ramblings on development
In a recent post I talked about using String.forall for string matching over the use of Regex:
I do however use Regex a lot for other types of processing. One thing I find myself doing a bit is capturing values from a Match. If you find yourself doing this a lot the Dynamic Lookup Operator allows one to define a simple model for extracting the captured group values:
The outcome of this code is:
The RegexCatcher type is a simple type that enables one to initialize a Regex, with an associated search string, and then providing access the captured groups:
Although the pattern is simple, I hope one will agree, that the code using this type is very succinct and easy to read.