I´m working on a project and the problem we need to solve is simple and a little bit old: map the best html that can be supported to the device.

The approach we had was to consult a huge table in a database based on wurfl and determine the profile. This has serious performance issues.

Our next idea é construct a set of regular expressions that supports this mapping. This set os regexps could be load in Apache (using RewriteMap and RewriteRules) ou in a hashtable in the application.

The questions are:
1- What is the best (and performatic) way to do this mapping?
2- If the regexps sets sounds a good idea, does anyone have any material or experience on that?