Generate RegExp for given hostname value.

@param (string|RegExp} val
@private
7868
function hostregexp (val) {
  var source = !isregexp(val)
    ? String(val).replace(ESCAPE_REGEXP, ESCAPE_REPLACE).replace(ASTERISK_REGEXP, ASTERISK_REPLACE)
    : val.source

  // force leading anchor matching
  if (source[0] !== '^') {
    source = '^' + source
  }

  // force trailing anchor matching
  if (!END_ANCHORED_REGEXP.test(source)) {
    source += '$'
  }

  return new RegExp(source, 'i')
}
467929
function extendFormatExtensions (extensionName, extensionValue) {
        if (typeof extensionName !== 'string' || !(extensionValue instanceof RegExp)) {
            throw new Error('extensionName or extensionValue undefined or not correct type');
        }

        if (revalidator.validate.formats.hasOwnProperty(extensionName) ||
            revalidator.validate.formats.hasOwnProperty(extensionName)) {
            var msg = 'extensionName: ' + extensionName + ' already exists in formatExtensions.';
            throw  new Error(msg);
        }

        revalidator.validate.formatExtensions[extensionName] = extensionValue;
    }
677190
function createRegex(value, modifier) {
    if (Type.isString(value)) {
        return new RegExp(value, modifier ? modifier : 'g');
    }
    throw new Error('Core.createRegex: Value is not string');
}
1230701
function replace(pattern, replacement, val){
  utils.assertString(pattern, 'pattern');
  utils.assertString(replacement, 'replacement');
  utils.assertString(val, 'val');
  pattern = new RegExp(pattern.string, 'g');
  var res = val.string.replace(pattern, replacement.string);
  return val instanceof nodes.Ident
    ? new nodes.Ident(res)
    : new nodes.String(res);
}
1346285
private String buildConstraintExpr(String device_name, String attribute, String event_name, String[] filters) {
        String str =
                "$domain_name == \'" + device_name.toLowerCase() + "/" +
                        attribute.toLowerCase() + "\'" + " and $event_name == \'" +
                        event_name + "\'";
        if (filters != null && filters.length != 0) {
            str += " and ((";
            for (String filter : filters)
                str += filter;
            str += " ) and $forced_event > 0.5 )";
        }
        return str;
    }
405480
function toRegexpSource(val, keys, options) {
  if (Array.isArray(val)) {
    return arrayToRegexp(val, keys, options);
  }

  if (val instanceof RegExp) {
    return regexpToRegexp(val, keys, options);
  }

  return stringToRegexp(val, keys, options);
}
849843
function (name, val) {
            function exec(name, val) {
                var reg = new RegExp('(^|;)\\s*' + name + ':([^;]+;?)', 'gi');
                cssStyle = cssStyle.replace(reg, '$1');
                if (val) {
                    cssStyle = name + ':' + utils.unhtml(val) + ';' + cssStyle
                }

            }

            var cssStyle = this.getAttr('style');
            if (!cssStyle) {
                cssStyle = '';
            }
            if (utils.isObject(name)) {
                for (var a in name) {
                    exec(a, name[a])
                }
            } else {
                exec(name, val)
            }
            this.setAttr('style', utils.trim(cssStyle))
        }
1201521
function(val){
			val = val.toLowerCase();
			var that = this;
			$.each( CPGlobal.stringParsers, function( i, parser ) {
				var match = parser.re.exec( val ),
					values = match && parser.parse( match ),
					space = parser.space||'rgba';
				if ( values ) {
					if (space === 'hsla') {
						that.value = CPGlobal.RGBtoHSB.apply(null, CPGlobal.HSLtoRGB.apply(null, values));
					} else {
						that.value = CPGlobal.RGBtoHSB.apply(null, values);
					}
					return false;
				}
			});
		}
606181
function (regexName, regex, content, results) {
      var r;
      _log.debug("---------------------------------------------------------------------------------------------------");
      _log.debug('Process extraction with regex : "' + regexName + '"');
      _log.debug(regex);
      regex.lastIndex = 0;
      while ((r = regex.exec(content)) !== null) {

        // Result expected [STRING, KEY, SOME_REGEX_STUF]
        // Except for plural hack [STRING, KEY, ARRAY_IN_STRING]
        if (r.length >= 2) {
          var translationKey, evalString;
          var translationDefaultValue = "";

          switch (regexName) {
            case 'HtmlDirectiveSimpleQuote':
            case 'HtmlDirectiveDoubleQuote':
              translationKey = r[1].trim();
              translationDefaultValue = (r[2] || "").trim();
              break;
            case 'HtmlDirectivePluralFirst':
              if (!r.length > 2) {
                return;
              }
              var tmp = r[1];
              r[1] = r[2];
              r[2] = tmp;
            case 'HtmlDirectivePluralLast':
              evalString = eval(r[2]);
              if (_.isArray(evalString) && evalString.length >= 2) {
                translationDefaultValue = "{NB, plural, one{" + evalString[0] + "} other{" + evalString[1] + "}" + (evalString[2] ? ' ' + evalString[2] : '') + "}";
              }
              translationKey = r[1].trim();
              break;
            default:
              translationKey = r[1].trim();
          }

          // Avoid empty translation
          if (translationKey === "") {
            return;
          }

          switch (regexName) {
            case "commentSimpleQuote":
            case "HtmlFilterSimpleQuote":
            case "JavascriptServiceSimpleQuote":
            case "JavascriptServiceInstantSimpleQuote":
            case "JavascriptFilterSimpleQuote":
            case "HtmlNgBindHtml":
              translationKey = translationKey.replace(/\\\'/g, "'");
              break;
            case "commentDoubleQuote":
            case "HtmlFilterDoubleQuote":
            case "JavascriptServiceDoubleQuote":
            case "JavascriptServiceInstantDoubleQuote":
            case "JavascriptFilterDoubleQuote":
              translationKey = translationKey.replace(/\\\"/g, '"');
              break;
            case "JavascriptServiceArraySimpleQuote":
            case "JavascriptServiceArrayDoubleQuote":
              var key;

              if(regexName === "JavascriptServiceArraySimpleQuote") {
                key = translationKey.replace(/'/g, '');
              } else {
                key = translationKey.replace(/"/g, '');
              }
              key = key.replace(/[\][]/g, '');
              key = key.split(',');

              key.forEach(function(item){
                item = item.replace(/\\\"/g, '"').trim();
                if (item !== '') {
                  results[item] = translationDefaultValue;
                }
              });
              break;
          }

          // Check for customRegex
          if (_.isObject(customRegex) && !_.isArray(customRegex) && customRegex.hasOwnProperty(regexName)) {
            if (_.isFunction(customRegex[regexName])) {
              translationKey = customRegex[regexName](translationKey) || translationKey;
            }
          }

          // Store the translationKey with the value into results
          var defaultValueByTranslationKey = function (translationKey, translationDefaultValue) {
            if (regexName !== "JavascriptServiceArraySimpleQuote" &&
              regexName !== "JavascriptServiceArrayDoubleQuote") {
              if (keyAsText === true && translationDefaultValue.length === 0) {
                results[translationKey] = translationKey;
              } else {
                results[translationKey] = translationDefaultValue;
              }
            }
          }

          // Ternary operation
          var ternaryKeys = _extractTernaryKey(translationKey)
          if (ternaryKeys) {
            _.forEach(ternaryKeys, function(v) {
              defaultValueByTranslationKey(v);
            });
          } else {
            defaultValueByTranslationKey(translationKey, translationDefaultValue);
          }

        }
      }
    }
1267543
function vhostof (req, regexp) {
  var host = req.headers.host
  var hostname = hostnameof(req)

  if (!hostname) {
    return
  }

  var match = regexp.exec(hostname)

  if (!match) {
    return
  }

  var obj = Object.create(null)

  obj.host = host
  obj.hostname = hostname
  obj.length = match.length - 1

  for (var i = 1; i < match.length; i++) {
    obj[i - 1] = match[i]
  }

  return obj
}
385758
function createNamedRegex(regexp, flags) {

    if (typeof regexp === "boolean") {
      // options parameter
      if (regexp === false) {
        cache = undefined;
      } else if (!cache) {
        cache = {};
      }
      return;
    }

    if (typeof regexp !== "string") {
      // parameter is regexp literal
      flags = (regexp.global ? "g" : "") +
        (regexp.multiline ? "m" : "") +
        (regexp.ignoreCase ? "i" : "");
      regexp = regexp.source;
    }

    var info = cache ? (cache[regexp] || (cache[regexp] = parseRegex(regexp))) : parseRegex(regexp);
    var regex = new RegExp(info.regexText, flags);

    regex.groupsIndices = info.mapper;

    function extendMatched(matched) {
      var mapper = info.mapper;
      /**
      * Returns value for group name or undefined. If same group name was defined multiple time, it returns first not undefined value.
      * If all is set to true, then it returns array of all matched values.
      */
      matched.group = function (name, all) {
        var indices = mapper[name];
        if (typeof indices === "number") {
          // name group is defined only once
          return matched[indices];
        } else if (all) {
          // name group is defined multiple time and because all is true, return array of all matched values
          return indices.map(function (v) { return matched[v]; });
        } else if (indices) {
          // name group is defined multiple time and because all is false, return first not undefined matched value
          for (var i = 0; i < indices.length; ++i) {
            var value = matched[indices[i]];
            if (value !== undefined) {
              return value;
            }
          }
        }
        return undefined;
      };
      var cachedGroups, cachedGroupsAll;
      matched.groups = function (all) {
        var cg = all ? cachedGroupsAll : cachedGroups;
        if (cg) {
          return cg;
        }
        cg = {};
        for (var name in mapper) {
          cg[name] = matched.group(name, all);
        }
        return all ? cachedGroupsAll = cg : cachedGroups = cg;
      };
      return matched;
    }

    regex.exec = function (text) {
      var matched = RegExp.prototype.exec.call(this, text);
      if (matched) {
        extendMatched(matched);
      }
      return matched;
    }
    regex.execGroups = function (text, all) {
      var matched = this.exec(text);
      if (!matched) {
        return null;
      }
      return matched.groups(all);
    }

    regex.replace = function (text, replacement) {
      if (typeof replacement === "function") {
        return text.replace(regex, function () {
          var matched = Array.prototype.slice.call(arguments, 0, arguments.length - 2);
          extendMatched(matched);
          return replacement.apply(matched, arguments);
        });
      } else {
        var replacementText = parseReplacement(replacement, this.groupsIndices);
        return text.replace(this, replacementText);
      }
    }
    return regex;
  }
143361
function (val) {
		var parseDate = this.options.parseDate,
			ret,
			key,
			format,
			dateFormat = this.options.dateFormat || this.dateFormat,
			match;

		if (parseDate) {
			ret = parseDate(val);
		
		} else if (typeof val === 'string') {
			// Auto-detect the date format the first time
			if (!dateFormat) {
				for (key in this.dateFormats) {
					format = this.dateFormats[key];
					match = val.match(format.regex);
					if (match) {
						this.dateFormat = dateFormat = key;
						this.alternativeFormat = format.alternative;
						ret = format.parser(match);
						break;
					}
				}
			// Next time, use the one previously found
			} else {
				format = this.dateFormats[dateFormat];
				match = val.match(format.regex);
				if (match) {
					ret = format.parser(match);
				}
			}
			// Fall back to Date.parse		
			if (!match) {
				match = Date.parse(val);
				// External tools like Date.js and MooTools extend Date object and
				// returns a date.
				if (typeof match === 'object' && match !== null && match.getTime) {
					ret = match.getTime() - match.getTimezoneOffset() * 60000;
				
				// Timestamp
				} else if (typeof match === 'number' && !isNaN(match)) {
					ret = match - (new Date(match)).getTimezoneOffset() * 60000;
				}
			}
		}
		return ret;
	}
1158550
function(value, text) {
      // escape regex characters
      text = text.replace($.fn.form.settings.regExp.escape, "\\$&");
      return (value.search( new RegExp(text, 'i') ) !== -1);
    }
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' );
			}
		}
	}
1277402
function(val) {
    var textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));

    // Fix for bug in IE 10/11 which causes placeholder text to be copied to "value"
    if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) {
      textArea.val(val);
      // TODO move this code outside of the view and expose an event instead
      if( this.model.jsonEditor && this.model.jsonEditor.isEnabled()){
        this.model.jsonEditor.setValue(JSON.parse(this.model.sampleJSON));
      }
    }
  }
414831
private void replaceHostLabelsWithStringSpecifier(String hostExpression) {
        if (StringUtils.isNullOrEmpty(hostExpression)) {
            throw new IllegalArgumentException("Given host prefix is either null or empty");
        }

        Matcher matcher = PATTERN.matcher(hostExpression);

        while (matcher.find()) {
            String matched = matcher.group(1);
            c2jNames.add(matched);
            hostWithStringSpecifier = hostWithStringSpecifier.replaceFirst("\\{" + matched + "}", "%s");
        }
    }
555006
private function matchHostPart($value, &$hostname, &$address) {
        $matches = [];
        $pattern = '~^(?P<name>[a-z0-9\-]+\.[a-z0-9\-\.]+)?\s*(\[(IPv[64])?(?P<addr>[a-f\d\.\:]+)\])?$~i';
        if (preg_match($pattern, $value, $matches)) {
            if (!empty($matches['name'])) {
                $hostname = $matches['name'];
            }
            if (!empty($matches['addr'])) {
                $address = $matches['addr'];
            }
            return true;
        }
        return false;
    }