You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
653 B
26 lines
653 B
class Utils {
|
|
/**
|
|
* Get first matched item for a string
|
|
* @param {RegExp} regexp
|
|
* @param {String} ua
|
|
* @return {Array|{index: number, input: string}|*|boolean|string}
|
|
*/
|
|
static getFirstMatch(regexp, ua) {
|
|
const match = ua.match(regexp);
|
|
return (match && match.length > 0 && match[1]) || '';
|
|
}
|
|
|
|
/**
|
|
* Get second matched item for a string
|
|
* @param regexp
|
|
* @param {String} ua
|
|
* @return {Array|{index: number, input: string}|*|boolean|string}
|
|
*/
|
|
static getSecondMatch(regexp, ua) {
|
|
const match = ua.match(regexp);
|
|
return (match && match.length > 1 && match[2]) || '';
|
|
}
|
|
}
|
|
|
|
module.exports = Utils;
|