Back to the Shapespark home page

RegEx in body-end.html

I’m trying to detect the iOS version in the user agent, and this line of javascript causes my project not to open.

var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);

I’m assuming there is an issue with escaping some of those regEx characters when the server merges the body-end into the main html file. Any thoughts?

@danscully, sorry, inserting body-end.html content is not escaping potential regex backreferences properly. We’ll fix it in the next release.

For now, could you use [0-9] instead of \d?
var v = (navigator.appVersion).match(/OS ([0-9]+)_([0-9]+)_?([0-9]+)?/);