code: function pattern (val, pat) {
    if (typeof pat !== 'string') { return false }
  
    var match = pat.match(new RegExp('^/(.*?)/([gimy]*)$'));
    if (!match) { return false }
  
    return new RegExp(match[1], match[2]).test(val)
  }
docs: pattern
  This function validate whether the value matches the regex pattern