@Test public void identifyIOSVersion_versionWithDots() { final String pix51 = "Pixellent 1.5.7 rv:31 (iPad; iPhone OS 5.1; de_DE)"; assertThat(VersionParser.identifyIOSVersion(pix51).toVersionString()).isEqualTo("5.1"); }
static VersionNumber identifyIOSVersion(final String userAgent) { VersionNumber version = VersionNumber.UNKNOWN; final List<Pattern> patterns = new ArrayList<Pattern>(); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("CPU OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\.\\d+)+)?);")); for (final Pattern pattern : patterns) { final Matcher m = pattern.matcher(userAgent); if (m.find()) { version = parseFirstVersionNumber(m.group(MAJOR_INDEX).replaceAll("_", ".")); break; } } return version; }
VersionParser { static VersionNumber identifyIOSVersion(final String userAgent) { VersionNumber version = VersionNumber.UNKNOWN; final List<Pattern> patterns = new ArrayList<Pattern>(); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("CPU OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\.\\d+)+)?);")); for (final Pattern pattern : patterns) { final Matcher m = pattern.matcher(userAgent); if (m.find()) { version = parseFirstVersionNumber(m.group(MAJOR_INDEX).replaceAll("_", ".")); break; } } return version; } }
VersionParser { static VersionNumber identifyIOSVersion(final String userAgent) { VersionNumber version = VersionNumber.UNKNOWN; final List<Pattern> patterns = new ArrayList<Pattern>(); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("CPU OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\.\\d+)+)?);")); for (final Pattern pattern : patterns) { final Matcher m = pattern.matcher(userAgent); if (m.find()) { version = parseFirstVersionNumber(m.group(MAJOR_INDEX).replaceAll("_", ".")); break; } } return version; } private  VersionParser(); }
VersionParser { static VersionNumber identifyIOSVersion(final String userAgent) { VersionNumber version = VersionNumber.UNKNOWN; final List<Pattern> patterns = new ArrayList<Pattern>(); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("CPU OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\.\\d+)+)?);")); for (final Pattern pattern : patterns) { final Matcher m = pattern.matcher(userAgent); if (m.find()) { version = parseFirstVersionNumber(m.group(MAJOR_INDEX).replaceAll("_", ".")); break; } } return version; } private  VersionParser(); static VersionNumber parseLastVersionNumber(@Nonnull final String text); static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent); static VersionNumber parseVersion(@Nonnull final String version); }
VersionParser { static VersionNumber identifyIOSVersion(final String userAgent) { VersionNumber version = VersionNumber.UNKNOWN; final List<Pattern> patterns = new ArrayList<Pattern>(); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("CPU OS\\s?((\\d+)((\\_\\d+)+)?) like Mac OS X")); patterns.add(Pattern.compile("iPhone OS\\s?((\\d+)((\\.\\d+)+)?);")); for (final Pattern pattern : patterns) { final Matcher m = pattern.matcher(userAgent); if (m.find()) { version = parseFirstVersionNumber(m.group(MAJOR_INDEX).replaceAll("_", ".")); break; } } return version; } private  VersionParser(); static VersionNumber parseLastVersionNumber(@Nonnull final String text); static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent); static VersionNumber parseVersion(@Nonnull final String version);  }