Declare a +RegexField+
423500
def regex(name, regexp, options = {})
      field name, RegexField.new(regexp, options)
    end
215020
def _compile(self, expression):
        

        x = self.RE_PYTHON_VAR.sub('(?:\\1,)', expression)
        x = self.RE_SPACES.sub('', x)
        return re.compile(x)
885899
function compareNumericField(field, a, b) {
    var nodeA = (a[1]);
    var nodeB = (b[1]);
    return nodeA[field] - nodeB[field];
  }
590633
function make_regex(tokens) {
	var str = tokens.reduce(function (res, token, index) {
			var is_last = (index == (tokens.length - 1));
			var before_multi = (index === (tokens.length - 2)) && (last(tokens).type == "multi");
			return res + ((is_last || before_multi) ? token.last : token.piece);
		},
		"");
	return new RegExp("^" + str + "$");
}
305364
function validateExpression( node ) {
		var args,
			len,
			re,
			i;

		if ( node.callee.name === 'RegExp' ) {
			len = node.arguments.length;
			args = new Array( node.arguments.length );
			for ( i = 0; i < len; i++ ) {
				// NOTE: we only support literals ATM. Otherwise, we may need to walk and implement an entire tree.
				if ( node.arguments[ i ].type !== 'Literal' ) {
					return;
				}
				args[ i ] = node.arguments[ i ].value;
			}
			re = RegExp.apply( null, args );
			if ( !safe( re ) ) {
				context.report( node, 'Unsafe regular expression' );
			}
		}
	}
1163883
def extend_regex(regexpr):
    
    """
    regex_map = {
        #r'\<': r'\b(?=\w)',
        #r'\>': r'\b(?!\w)',
        r'\<': r'\b' + positive_lookahead(r'\w'),
        r'\>': r'\b' + negative_lookahead(r'\w'),
        ('UNSAFE', r'\x08'): r'\b',
    }
    for key, repl in six.iteritems(regex_map):
        if isinstance(key, tuple):
            search = key[1]
        else:
            search = key
        if regexpr.find(search) != -1:
            if isinstance(key, tuple):
                print('WARNING! Unsafe regex with: %r' % (key,))
            regexpr = regexpr.replace(search, repl)
    return regexpr
306376
function buildRegex(pattern) {
    var re = pattern
      .replace(escapeRegex, '\\$&')
      .replace(namedParam, '([^/]*)')
      .replace(splatParam, '(.*?)');

    return new RegExp('^' + re + '$');
  }
179327
function(props, regex) {
            if(!(regex instanceof RegExp)) {
                return props;
            }
            var key,
                filtered = {};

            for(key in props) {
                if(props.hasOwnProperty(key) && regex.test(key)) {
                    filtered[key] = props[key];
                }
            }
            return filtered;
        }
660182
def _wrap_value_with_context(self, value: dict or str, field_name: str, start: int=0, end: int=0) -> Extraction:
        """"""
        return Extraction(value, self.name, start_token=start, end_token=end, tag=field_name)
315771
public static boolean validateOptionalField(String field, String reg) {
        if (field == null || field.isEmpty()) {
            return true;
        }
        return Pattern.matches(reg, field);
    }
1034685
function regExpBuilder (find) {
  const regExpRe = /\/(.*)\/(\w*)/
  if (find) {
    if (regExpRe.test(find)) {
      const matches = find.match(regExpRe)
      const pattern = matches[1]
      const flags = matches[2]
      return new RegExp(pattern, flags)
    } else {
      return find
    }
  } else {
    return null
  }
}
296462
function regexify (admin) {
            client.note("PluginAdmin", format("Adding admin: %j", admin));

            names.forEach(function (name) {
                if (admin[name]) {
                    admin[name] = new RegExp(admin[name], "i");
                } else {
                    admin[name] = anyRegex;
                }
            });

            return admin;
        }
93792
def _regexp(expr, item):
    ''' 
    '''
    reg = re.compile(expr)
    return reg.search(item) is not None
471204
function(el, value)
	{
		// TODO Restrict to text input fields?
		
		if (el.cbRestrict)
		{
			el.removeEventListener('keypress', el.cbRestrict);
		}
		
		el.cbRestrict = function(event)
		{
			if (event.ctrlKey)
			{
				return;
			}
			
			var code = event.keyCode || event.which;
			var char = event.key || String.fromCharCode(code);
			var regExp = value;
				
			if (!conbo.isRegExp(regExp))
			{
				regExp = new RegExp('['+regExp+']', 'g');
			}
			
			if (!char.match(regExp))
			{
				event.preventDefault();
			}
		};
		
		el.addEventListener('keypress', el.cbRestrict);
	}
568643
public static boolean validateRequiredField(String field, String reg) {
        return !(field == null || field.isEmpty()) && Pattern.matches(reg, field);
    }
54017
function (template) {
    var pattern = _.template(template)(fileReplace);
    pattern = pattern.replace(/\//g, '\\/');
    pattern = pattern.replace(/\s+/g, '\\s*');
    pattern = '\\s*' + pattern + '\\s*';
    return new RegExp(pattern);
}
550044
function(matches, index, tokens, regexValue) {
      var i = tokens.length;

      while (--i >= 0) {
        var token = tokens[i];
        var type = token.type;

        if (type === _Comment ||
            type === _WhiteSpace ||
            type === _LineTerminator) {
          continue;
        }

        var value = token.value;
        if (type === _Punctuator) {
          if (value === ')') {
            if (this.isValidRegExpPrefix(tokens, i + 1)) {
              break;
            }
          } else if (regexPrefixRe.test(value)) {
            break;
          }
        } else if ((type === _Keyword && regexPrefixRe.test(value)) ||
                   (type === _Template && value.slice(-2) === '${')) {
          break;
        }

        var parts = regexValue.match(tokenizeNotRegExpRe);
        splice.apply(matches, [index, 1].concat(parts));
        return true;
      }
      return false;
    }