Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3439612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:19:53+00:00 2026-05-18T08:19:53+00:00

I found a method online for separating out views when viewing a Ruby on

  • 0

I found a method online for separating out views when viewing a Ruby on Rails application on an iPhone and it parses the user agent to detect this. I’m specifically targeting iOS 4.2+ since previous versions don’t support HTML5 Web Sockets which I need for my application.

So far I am parsing /(iPhone.+OS.+4_2.+Safari)/ and it seems to work a treat but the problem I am having is that if you were using a beta or a future version of the OS the user agent might not include 4_2 but it may support Web Sockets.

My question is.. how could I parse the string to have the following outcome:

  • If there is a 4 or bigger
  • (Optional?) Followed by anything

My Regex is terrible, so excuse the daft question 🙂

Thanks in advanced!
Tom.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:19:53+00:00Added an answer on May 18, 2026 at 8:19 am

    It’s not actually possible to “reliably” parse a user-agent string; several common User-Agent strings violate HTTP 1.1 (I forget the RFC number) WRT the characters allowed between the parentheses (. or / or ; or something?). User-Agent sniffing is pretty fragile when you want to “whitelist” certain features and leads to complaints about preferential treatment of some browsers over others (especially when it’s Microsoft doing it), and means that someone has to keep giant regex updated.

    Is there really no better way (e.g. with JavaScript?) to detect the features that the browser supports?

    Nevertheless, you can do something like ; *CPU +iPhone +OS +(4_(2|[3-9]|\d\d)|[5-9]|\d\d)\[0-9a-zA-Z_]* +like +Mac +OS +X *;.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone found a good method of mocking out ADO.Net Data Service calls from
I'm converting an application to use Java 1.5 and have found the following method:
I found this page describing the Muenchian method, but I think I'm applying it
What's the easiest method people have found to monitor memcached on Windows? One method
The only reliable method that I a have found for using a script to
What's the Hi/Lo algorithm? I've found this in the NHibernate documentation (it's one method
I found this nice snippet of code online: rkApp = Registry.LocalMachine.OpenSubKey(SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run, true); Which runs
I'm trying to modify some code I found online to my needs. It is
Okay, I have done a bit of searching online and found this thread, but
I know many people experience this problem, but the solutions I found online do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.