Plain Text Transmogrification through Regular Expression Sorcery
Plain Text is everywhere and it isn’t always present in exactly the format you would like it to be in. Take for example an address line like this one; “Pottsville, PA 17901”, that is in a single field (or xml element). The data needs to be separated into city, state, and zip code fields. Luckily there is a pattern to the address data, although the city name may vary in length and might include spaces such as in “New York”, there is always a comma and space before a two letter state abbreviation, another space and then a five digit zip code.
Now, I could write a little parsing program or perhaps use several string manipulation functions in my translator to get what I want, but I know a little something about Regular Expressions (regex). Read more…