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

  • SEARCH
  • Home
  • 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 8553415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:38:46+00:00 2026-06-11T14:38:46+00:00

I am trying to find a regex that gets the iOS version from all

  • 0

I am trying to find a regex that gets the iOS version from all the iOS devices. I can’t do one seperately for each device type (iphone, ipad, ipod), I need a generic one.

Before I do the match, I check if it is a valid iOS device. The solution I have come up with is:

Match match = Regex.Match(HttpContext.Current.Request.UserAgent, @"(?<version>\d+(_\d+)+) like Mac OS X");
string versionNr = match.Groups["version"].ToString().Replace("_", ".");

I have checked quite a few devices agent strings, and so far they all match. But I am a bit worried that it wont match all, and just checking if anyone has a better regex.

Thanks in advance.

  • 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-06-11T14:38:48+00:00Added an answer on June 11, 2026 at 2:38 pm

    As mentioned in other answers, regex is not 100% reliable for testing user agent strings, but to answer the question how about this:

    (i[PSa-z\s]+);.*?CPU\s([OSPa-z\s]+(?:([\d_]+)|;))
    

    The first match group is the type iPhone/pad/pod and the second group is the IOS version (except for IOS 1 where no version number is present)

    The corpus used may be missing some of the user agents, but you can fiddle with it.

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

Sidebar

Related Questions

trying to write an regex that can find all patterns p = q=http://.*\.doc in
I am trying to create a regex that helps Eclipse's search find all lines
I am trying to write a RegEx rule to find all a href HTML
I'm trying to find a regex that will check for a valid mask. The
I'm trying to find a regex that works to match a string of escape
I'm trying to write a regex pattern that will find numbers with two leading
I'm trying to find a RegEx that will allow the digits 0-9 ONLY and
I'm trying to find the regex in java that matches a substring with TTFI
I am trying to find a regex to limit what a person can use
I'm trying mount a regex that get some words on a file where all

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.