JSFiddle - React, Tailwind, and code Playground
JavaScript
function getMatches (str) {
var reg = /(min|max)-width\s*:\s*(\d*\.?\d+)/g, ret = [undefined, undefined], arr;
while ((arr = reg.exec(str)) !== null) {
ret[+(arr[1] === "max")] = arr[2];
}
return ret;
}
console.log( getMatches("only screen and (min-width: 500px) and (max-width: 599px)") );
console.log( getMatches("only screen and (min-width: 500px)") );
console.log( getMatches("(max-width: 599px)") );