Uncommon Regular Expressions That Should Be

For some strange reason I was recently surprised to find that regexes that should be common were no where to be found inside the interweb.  So here they are.

This is a Regex for an IP address:

^(?:(?:25[0-5]|2[0-4]\d|[1]\d\d?|[1-9]\d?|[0])\.){3}(?:25[0-5]|2[0-4]\d|[1]\d\d?|[1-9]\d?|[0])$

Notice that it does use those fancy extensions which have a wonderful description in the python documentation for the regular expression module named re.  This allows only IP addresses that would be valid in a bind zone file (my reason for needing this regex). That is it dissallows any number higher than 255 in any octet and does not allow zeros to lead any of the octets — an important oversight in many IP address regexes in the web.

And here is a regex for a fully qualified domain name:

^(?:(?!-)[a-zA-Z0-9]+(?:-+[a-zA-Z0-9]+)*\.)+[a-zA-Z]{2,4}\. $

This is for fully qualified domain names based on RFC 952 and 1123. Meaning that we do not allow any underscores inside the domain name or any of the other slack rules that were introduced in 2181. Also the GTLDs change enough (and they are making it easier to create new GTLDs) that it is futile to try limiting the top level domain with a regex. If you really want to know if the domain name is valid then resolve it yourself — I just want to know that it is in a valid format. For more information on valid names check out this link.

I have used these regular expressions in Python, Javascript and PHP, but they should work pretty much anywhere as long as the extensions are supported.

pixelstats trackingpixel

Tags:

No Comments


Slow Push Navigation Button

This is as much informative as it is an archive so that I will remember how to create this again. This will make a fancy navigation bar with buttons that will transform slowly when the mouse is hovering over them. It creates a neat effect that button is being pressed and this could be extended so that when you click it transforms the button again making it look like it is being pushed into the screen. As opposed to some other navigation menus that require a new image be made for each menu item (the text being part of the image) this navigation bar will use a normal anchor with text node for the link text. Here is a live example of the navigation bar.

Read the rest of this entry »

pixelstats trackingpixel

No Comments


Fast & Furious Review

Trademark look; eyes half-closed and looking confusedFor my first movie review I chose something with a very simple plot. Something that is so blatantly laid out that it will be easy for people to understand my review.This is especially important because I did not watch the entire movie. I was passing in and out of sleep during the film and I haven’t seen the three prequels to Fast & Furious. I have seen other Vin Diesel movies; and they are pretty much all related to each other. Dominic, Richard, and Xander are the same character in emotion, facial expressions, personality, and hair length.

In this particular film Vin Diesel’s goal is to kill Mr T. Apparently Mr T killed Vin’s latina lover; Vin finds this out through a flashback very early in the film. This isn’t a true flashback of course, because Vin  was in Mexico hiding from the law when it happened. A drug induced hallucination is more likely the reason he thinks Mr T killed her. From this quick description you can infer what the rest of the plot is; the standard vengeance story.

What you won’t be able to figure out is why the FBI never think to check Vin’s sisters (his only family) house to see if he is visiting during the funeral. Did I mention that his sister in this film is Hispanic — for those of you unfamiliar Vin Diesel is mighty white. There are several other points that you have to avoid thinking too hard about, but we can leave plot holes in the background of an action movie.

Mr TAs expected there are many fast car chase action sequences. Unfortunately they are usually more car then chase. All the camera shots are closeups of the cars body and rarely does it pan out enough to see a road underneath. I have a notion that the car is just sitting there — with Vin making car noises inside. The action sequences may be hazardous to people with epilepsy as they flicker incessantly due to the scene being cut every few seconds. I would like to attribute this to bad camera work, but I have a suspicion that Vin could not get through more than three words before fucking something up — two words if one of them is over three syllables.

Putting the awful story, plot holes, implausible story lines, predictable speaking lines, poor camera work, and horrendous acting aside this was still a terrible movie. Don’t watch it — ever.

pixelstats trackingpixel

Tags: ,

No Comments



SetPageWidth