Then you would have to have the complete USER_AGENT string for each possible browser, which isn't really viable. Each string contains (usually) information about both the browser name, version and the OS. That is a lot of strings.

Update:

Ah, the regexp; the good old hammer. Tell you what. I spent 30 seconds looking in my perlmonk.org web log (which does *not* get any significant amount of traffic), and just from this fast survey, I could pick out this list easily:

Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt; DTS Agent Mozilla/3.0 (compatible; Indy Library) Mozilla/5.0 Galeon/1.2.1 (X11; Linux i686; U;) Gecko/20020417 Mozilla/4.78 [en] (X11; U; Linux 2.4.7-10 i686) Mozilla/4.5 (compatible; iCab 2.7.1; Macintosh; I; PPC) Mozilla/5.0 (Linux 2.4.7-10 i586; U) Opera 6.0 [en] Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 6.01 [en]
Sure looks easy to write a regexp that picks out the important part, yes? When should we pick something inside the paranthesis? Outside? What if the paranthesis doesn't close? Is it MSIE or Opera? I'm sure it is easy; please show me.


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

In reply to Re(4):Short and Sweet Browser Detection by Dog and Pony
in thread Short and Sweet Browser Detection by hacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.