Bryntum Quiz 3
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
/*
3. Write a single RegExp to extract the Ext JS version identifier (e.g. “3.4.0”, or “4.1.1-rc-1”) out of the URLs below. Note, that URLs potentially can point to some other resource with similar URL (for example ext-all-this-is-not-ext.js), in which case the RegExp should not match.
http://bryntum.com/examples-1.2.3/advanced/advanced.html
http://bryntum.com/doc/1.2.3/foo/bar.html
http://cdn.sencha.io/ext-3.4.0/ext-all-debug.js
http://cdn.sencha.io/ext-3.4.0-beta-1/ext-all.js
http://cdn.sencha.io/extjs-4.1.0-rc-1/ext-all-debug.js
http://bryntum.com/examplesfor/extjs-4.1.1/foo/bar.html
http://bryntum.com/library/extjs-4.1.2/ext-all-debug.js
http://bryntum.com/library/extjs-10.11.21/ext-all-debug.js
http://bryntum.com/library/extjs-4.1.2/ext-all-this-is-not-ext.js
*/
var urls = [
'http://bryntum.com/examples-1.2.3/advanced/advanced.html',
'http://bryntum.com/doc/1.2.3/foo/bar.html',
'http://cdn.sencha.io/ext-3.4.0/ext-all-debug.js',
'http://cdn.sencha.io/ext-3.4.0-beta-1/ext-all.js',
'http://cdn.sencha.io/extjs-4.1.0-rc-1/ext-all-debug.js',
'http://bryntum.com/examplesfor/extjs-4.1.1/foo/bar.html',
'http://bryntum.com/library/extjs-4.1.2/ext-all-debug.js',
'http://bryntum.com/library/extjs-10.11.21/ext-all-debug.js',
'http://bryntum.com/library/extjs-4.1.2/ext-all-this-is-not-ext.js'
];
var extJsVersionRegExp = /\d.*\d(?=.*\/(?:ext-all-debug.js|ext-all.js)$)/;
for (var i=0, iMax=urls.length; i<iMax; i++) {
console.log( extJsVersionRegExp.exec(urls[i]) );
}