var getPrefixes = function()

in srs_extension/reqparser.js [40:60]


var getPrefixes = function (text) {
    // This will match (prefix as group 1_)(devId_reqId)
    // Then we can strip off the dev ID and requirement ID, but we allow numbers in the prefix
    var regex = /(SRS_[0-9A-Z_]+_)([0-9]{2}_[0-9]{3})/g;
    var prefixes = Array.from(text.matchAll(regex));
    var dedupedPrefixes = null;

    if (prefixes != null) {
        // First strip the dev ID and requirement ID's (first array item in regex match is everything, second is the first group that we want, index 1)
        prefixes = prefixes.map(function (item){
            return item[1];
        });

        // Then de-duplicate
        dedupedPrefixes = prefixes.filter(function (item, pos, self) {
            return self.indexOf(item) == pos;
        });
    }

    return dedupedPrefixes || [];
};