Jane Bailey

Jane Bailey is a self-published author of urban fantasy novels as well as a part-time blogger; in their day job, they're a renaissance person, dabbling in all sorts of fields in search of interesting puzzles and finding mostly WTFs.

Feb 2015

The Address Shuffle

by in CodeSOD on

The best thing about being a consultant, in Ashleigh's opinion, was that you got to leave at the end of a job- meaning you never had to live with the mistakes your pointy-haired supervisor forced on you.

August 1970 DETAIL ORNAMENTED MAILBOX - Morris-Butler House, 1204 North Park Avenue, Indianapolis, Marion County, IN HABS IND,49-IND,9-13


How to Validate a URL

by in Representative Line on

INTERNET!There's an old joke among programmers, particularly those who have had to use regexes more often than they're comfortable with:

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
It's a seductive trap: Regexes are good at processing strings, and are more complex than your usual string-processing utilities, so it seems logical to use regexes to do advanced string-parsing. But regular expressions are not meant to do arbitrary string parsing. Regular expressions are meant to parse regular languages. Furthermore, regular expressions are notoriously hard to read, resulting in, what appears to be, a string of random characters sneezed out all over your screen. For example, consider the following that's used for parsing a valid URL:


Regex regex =new Regex(
  @"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$"
);