As other people have already noted, feature detection is preferred over checking for a specific browser. One reason is that the user agent string can be altered. Another reason is that the string may change and break your code in newer versions.
If you still want to do it and test for any Safari version, I'd suggest using this
var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
navigator.userAgent &&
navigator.userAgent.indexOf('CriOS') == -1 &&
navigator.userAgent.indexOf('FxiOS') == -1;
This will work with any version of Safari across all devices: Mac, iPhone, iPod, iPad.
Edit
To test in your current browser: https://jsfiddle.net/j5hgcbm2/
Edit 2
Updated according to Chrome docs to detect Chrome on iOS correctly
It's worth noting that all Browsers on iOS are just wrappers for Safari and use the same engine. See bfred.it's comment on his own answer in this thread.
Edit 3
Updated according to Firefox docs to detect Firefox on iOS correctly