All scripts that I can find that detect user browser and version info will give me something like, for example, "Netscape 5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5" instead of "Safari 5". Not pretty. How do sites like [whatbrowser.org ] show it so nicely?
In order to get something like "Safari 5" you can write a script to intelligently parse the user agent for the appropriate parts you are looking for. This will work OK for the main browsers. If you need to dig deeper and try to identify all browsers / robots / crawlers then you probably need to look up the user agent in some kind of database.