thebuilder/react-docs-markdown · index.js
javascript logo
function toRegExp(input) {
  if (!input) return null
  if (Array.isArray(input)) return new RegExp(`(${input.join('|')})`, 'i')

  return new RegExp(input, 'i')
}
Similar code snippets
1.
avwo/whistle · index.js
Match rating: 56.1% · See similar code snippets
javascript logo
function toRegExp(regExp, ignoreCase) {
  regExp = REG_EXP_RE.test(regExp);
  try {
    regExp = regExp && new RegExp(RegExp.$1, ignoreCase ? 'i' : RegExp.$2);
  } catch(e) {
    regExp = null;
  }
  return regExp;
}
2.
intesso/connect-livereload · index.js
Match rating: 54.51% · See similar code snippets
javascript logo
function () {
    var matches = rules.map(function (item) {
      return item.match.source;
    }).join('|');

    return new RegExp(matches, 'i');
  }
3.
janus-toendering/options-parser · types.js
Match rating: 53.12% · See similar code snippets
javascript logo
function(msg, regexp)
{
	if(!util.isRegExp(regexp))
		regexp = new RegExp(regexp);
	
	msg = msg || "Invalid value";
	return function(value, replace)
	{
		return regexp.test(value) || msg;
	}
}
4.
RallyTools/rally-node · ref.js
Match rating: 52.2% · See similar code snippets
javascript logo
function match(input) {
  input = (input && input._ref) ? input._ref : (input || '');
  const regexMatch = _.find(REF_REGEXES, regex => regex.test(input));
  return (regexMatch && input.match(regexMatch)) || null;
}
5.
jlenoble/child-process-data · get-message.js
Match rating: 51.44% · See similar code snippets
javascript logo
function toRegExp(msg) {
  var regex = msg;

  if (!(regex instanceof RegExp)) {
    regex = new RegExp(msg.toString().replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
  }

  return regex;
}
6.
avwo/whistle · util.js
Match rating: 51.33% · See similar code snippets
javascript logo
function(regExp) {
  if (!regExp) {
    return;
  }
  regExp = REG_EXP.test(regExp);
  try {
    regExp = regExp && new RegExp(RegExp.$1, RegExp.$2);
  } catch(e) {
    return;
  }
  return regExp;
}
7.
0xdec/draft.js · length.js
Match rating: 50.95% · See similar code snippets
javascript logo
function(val, regex) {
  // TODO: strict match anchor (^ instead of word end)
  regex = new RegExp(`${regex}$`, 'i');
  val = regex.exec(val);
  return val ? val[0].toLowerCase() : false;
}
8.
idanwe/meteor-client-side · meteor-client-side.bundle.min.js
Match rating: 50.79% · See similar code snippets
javascript logo
function(regexp){return function(value){if(value instanceof RegExp){return _.isEqual(value,regexp)}if(typeof value!=="string")return false;regexp.lastIndex=0;return regexp.test(value)}}
9.
tarruda/super-json · super-json.js
Match rating: 50.21% · See similar code snippets
javascript logo
function(regExp) {
    var flags = '';
    if (regExp.global) flags += 'g';
    if (regExp.multiline) flags += 'm';
    if (regExp.ignoreCase) flags += 'i';
    return [regExp.source, flags];
  }
10.
wilmoore/uuid-regexp.js · index.js
Match rating: 49.82% · See similar code snippets
javascript logo
function re (opts) {
  opts = opts || {}

  return new RegExp(
    format('\\b(?:%s)\\b', regexp.versioned.source + (opts.nil ? '|' + regexp.nil.source : '')),
    'i' + (opts.flags || '')
  )
}