There really ought to be a #DOM API that exposes the #UserAgent string in nicely tokenized form.
I guess browser people don't want to encourage browser detection, but it's not my fault their code has bugs I have to work around, and checking for a User-Agent token with regex isn't super reliable.