Updates to Regex Tester

I've updated my old regular expression testing tool. Previously, it only did ColdFusion 8 regular expression testing. Now it also performs tests against Java's regular expression matching. Click here to view my ColdFusion 8 and Java Regex Tester.

 

IIS vs onMissingTemplate

Several weeks back I was exposed to Python and Django for the first time, and it really got me thinking. While I'm not a huge fan of Python syntax, I really did like the setup for Django, and how it implements MVC. One of the first things that I loved was this little tid-bit for linking up URL requests to views:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P<poll_id>\d+)/results/$', 'mysite.polls.views.results'),
(r'^polls/(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
)

In that block, Django is defining regular expressions that map to Python functions, and defining how to pull named variables out of that regular expression, so that if you requested /polls/23/ becomes a call to the mysite.polls.views module to do the following:

# mysite.polls.views is the module, details is the function
detail(request=<HttpRequest object>, poll_id='23')

Isn't that cool? I'd love to be able to do that in ColdFusion, but it looks like there are a number of hurtles I have to get past before I can make this work:

  1. How do I make ColdFusion get the variables out of that URL path?
  2. How do I make ColdFusion look at a URL that doesn't exist?

 

No Blogs from CFUnited

In case someone out there was wondering, I had to give up on blogging my sessions from CFUnited when my laptop decided to start spazzing out. I'm not sure if I need to download more updates or what, but it would randomly rev my fan, and it was making enough racket that I had to stop using it during sessions.

So much for that.

I did have a blast though. I went 4-2 for stumping Adobe guys on why Peter Bell, who's talks on RAD OO and Code Generation where very nice, and Marc Esher of MXUnit who did an awesome presentation on Ant and its role in managing program deployment.

 

Leveraging Popular Frameworks

This contains info from the CFUnited talk on this topic.

This talk covers MVC, Factories, ORM Introducing a quick start application: AppBooster

Domain & Business objects for each Entity.

Business Object (bean) - people, places, and things, the nouns in your system. Data Access Objects (DAO) - read and save objects Gateways - Objects which return queries Service Object (SO) - your API (controllers do not touch BO, DAO, or Gateway) Controllers - talk to your service layer.

Q: Where is validation at? A: In the BO, or the SO.

Frameworks and Software Layers

DB Layer (ORM) Transfer, Reactor

continue later

 

CFUnited 2008

So, I'm at CFUnited 2008 at the Washingto Convention Center here in DC. Its always a nifty experiance to be at CFUnited, and this year has thus far been no exeption, even though its just getting started. I'd bore you all with notes from the keynote presentations from Michael Smith of TeraTech and Ben Forta and Adam Lehman of Adobe, but I'm not sure many tech people even look at the blog, so I wont bore you.

 

Javascript isValid()

I dunno about you, but I love the isValid() function in ColdFusion. Its just an amazing collection of usefulness that I use just about all the time. Recently though, I've found myself really wanting something equivalent for client-side validation, so I put together this bit of Javascript code:


function isValid (type, value) {
    var regex;
    
    switch (type.toLowerCase()) {
        case 'email':
            regex = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
            break;
        case 'telephone':
            regex = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
            break;
        case 'date':
            regex = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
            break;
        case 'numeric':
        case 'number':
            regex = /^[\d\.]+$/;
            break;
        case 'integer':
            regex = /^\d+$/;
            break;
        case 'zipcode':
            regex = /^\d{5}([\-]\d{4})?$/;
            break;
    }
    
    return value.match(regex);
}

Please note that I take no credit for the regular expressions used in this function. I collected them from various sources, and I would credit the original creator if I could find my list of where I got them.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.