Considering the Labor Day Weekend, look for a post on Wednesday of next week on the topic of Test Driven Regex.
While you wait, consider that regular expressions are a super powerful way to parse strings. That said, I like to joke that given a parsing problem you can find a regular expression. Now you have three problems.
Regular Expressions can be very challenging to learn and can often be very fragile. That said, they provide a concise means of parsing complicated string data into something you can easily use.
Working on my example of how to TDD a regular expression I came up with this simple (and still somewhat dumb) regex for at least one form of ISO 8601 Date-Time strings.
Using the Python re library, this regex will quickly chop up a date-time string. This is kind of silly since there are plenty of date-time parsers in the world; I picked this example because its still reasonably simple.
In any case you might find yourself in need of a custom string parser and regex is a great way to get there. Doing it with tests can be challenging though. There are lots of funny edges to be considered.
So, if all goes well, I'll have an example for you next week. Until the, enjoy the holiday.
Post a Comment
Note: Only a member of this blog may post a comment.