Regular Expressions

I just love Regular Expressions. I first came in to contact with them many years ago while doing Perl development. Anyone having to pull data out of text documents or textual input fields must become familiar with Regex as the alternatives of linear token parsing or token searching pale in comparison to the intelligent parsing capability of a regular expression.

PCRE has become a cross-platform/cross-language standard for Regular Expressions supported in whole or part in Perl, PHP, Python, Ruby, C#, Javascript, and Actionscript.


Phone Number

Parses a 10-digit phone number optionally followed by an extension.

Expanded and documented:

These values will all be parsed successfully. Group captures are marked in red (1), green (2),  blue (3), and orange (4):

  • 9999999999
  • 1-9999999999
  • (999) 9999999
  • 1(999) 9999999 ext 9999
  • (999) 9999999 x 9999
  • 99999999999999
  • 1-9999999999+9999

City, State, Zip Code

Parses City, State, and Zip Code.

Expanded and documented:

These values will all be parsed successfully. Group captures are marked in red (1), green (2),  blue (3), and orange (4):

  • Los Angeles, CA 90037
  • Fort Atkinson, WI 53538-0901 USA
  • New York NY 10001

By Any Other Color

The term “colored” was used to describe black folks and was printed on public signs in segregated parts of the country to point out “colored-only” facilities such as restrooms and drinking fountains. The term became synonymous with racism and its use has for some time been considered in bad taste and certain to illicit an angry response especially from the black community–as Benedict Cumberbatch recently found.

Yet, for a while now I’ve been hearing the term “people of color,” used to describe non-whites, from social media and news programs and have wondered why that term is okay and the other is not. Certainly it has not illicited the same controversy and it absolutely should.

How can people say there is no longer racism in this country when our institutions still differentiate people by their skin color such that some are “white” and the rest are “people of color?” “Non-whites” is a reasonable term to describe something effecting everyone but white people although “non-Caucasian” is certainly better. “People of color” is no less offensive to me than “colored” and I would bet it is to “non-whites” as well. if our social and institutional media still casually drops all non-white folks into the “colored” bucket, as if to say that “white” is somehow different, pure, or not of “color,” then racism is certainly alive and well in this country and permeates our society in subtle ways that a lot of us are failing to recognize.

White is a color, just like black, red, yellow, and brown. In fact, in computer graphics, it’s all the colors. So we are all “people of color,” period, the end, case closed.

How about we just say we’re all “people” and call it a day?