Friday, February 24, 2006

Undocumented regular expression pattern

UK Postcode validation is the theme for me today, and the standard has been very useful. Digging a little deeper even provides a couple of regular expression patterns for doing the validation with, both a simple one and a more complicated one.

Examining the patterns has led me to a construct that I can't find documented anywhere. I've looked through all the linked pages in the "Regular Expression Language Elements" section in the VS2005 help, but with no joy. It seems to work though.

[A-Z-[CIKMOV]]

Fairly self-explanatory hopefully, with this particular example matching any one of twenty capital letters. If it is actually documented somewhere, please do point me at it.

1 comment:

John Hartnup said...

After we discussed it the other day, I thought it ought to go documented for your readers.

This feature does not work in Perl, grep or egrep. Nor does any variation I can guess at, not does any equivalent appear in any documentation I can find.

Hence, consider this a .Net only feature, for now.