2 var semverRegex = require('semver-regex');
3 var arrayUniq = require('array-uniq');
5 module.exports = function (str, opts) {
6 if (typeof str !== 'string') {
7 throw new TypeError('Expected a string');
12 var reLoose = new RegExp('(?:' + semverRegex().source + ')|(?:v?(?:\\d+\\.\\d+)(?:\\.\\d+)?)', 'g');
13 var matches = str.match(opts.loose === true ? reLoose : semverRegex()) || [];
15 return arrayUniq(matches.map(function (el) {
16 return el.trim().replace(/^v/, '').replace(/^\d+\.\d+$/, '$&.0');