Also only allow alphanumberic and dash "-" and underscore "_"
10444
private void validateName(String name) throws DDFException {
    Boolean isNameExisted;
    try {
      this.getManager().getDDFByName(name);
      isNameExisted = true;
    } catch (DDFException e) {
      isNameExisted = false;
    }
    if(isNameExisted) {
      throw new DDFException(String.format("DDF with name %s already exists", name));
    }

    Pattern p = Pattern.compile("^[a-zA-Z0-9_-]*$");
    Matcher m = p.matcher(name);
    if(!m.find()) {
      throw new DDFException(String.format("Invalid name %s, only allow alphanumeric (uppercase and lowercase a-z, " +
          "numbers 0-9) and dash (\"-\") and underscore (\"_\")", name));
    }
  }
1254243
def slugify(value, allow_dots=False, allow_unicode=False):
    
    if allow_dots:
        pattern = _re_pattern_allow_dots
    else:
        pattern = _re_pattern

    value = six.text_type(value)
    if allow_unicode:
        value = unicodedata.normalize('NFKC', value)
        value = pattern.sub('', value).strip().lower()
        return _re_spaces.sub('-', value)
    value = unicodedata.normalize('NFKD', value).encode(
        'ascii', 'ignore').decode('ascii')
    value = pattern.sub('', value).strip().lower()
    return _re_spaces.sub('-', value)
940208
function(sStyle, sNumber, sPlural) {

			var sFormat;
			var oFormats;

			switch (sStyle) {
			case "long":
				oFormats = this._get("decimalFormat-long");
				break;

			default: //short
				oFormats = this._get("decimalFormat-short");
				break;
			}

			if (oFormats) {
				var sName = sNumber + "-" + sPlural;
				sFormat = oFormats[sName];
				if (!sFormat) {
					sName = sNumber + "-other";
					sFormat = oFormats[sName];
				}
			}

			return sFormat;

		}
449995
function slugify(s, opts) {
  opts = opts || {};
  s = str(s);
  if (!opts.mixedCase) { s = s.toLowerCase(); }
  return s
    .replace(/&/g, '-and-')
    .replace(/\+/g, '-plus-')
    .replace((opts.allow ?
      new RegExp('[^-.a-zA-Z0-9' + _.escapeRegExp(opts.allow) + ']+', 'g') :
      /[^-.a-zA-Z0-9]+/g), '-')
    .replace(/--+/g, '-')
    .replace(/^-(.)/, '$1')
    .replace(/(.)-$/, '$1');
}
1084541
function cleanDoctype(name) {
  return String(name)
    .toLowerCase()
    .replace(/([a-z]+|\d+)/, ' $1 ')
    .replace(/\.0+(?!\d)/, '')
    .replace(/\.01/, '')
    .replace(/\.2/, '')
    .replace(
      /\b(xhtml|html|mathml|svg|full|basic|tiny|strict|frameset|basic)\b/g,
      character
    )
    .replace(/ t(?:ransitional)?/, '')
    .replace(/\s+/g, '')
}
828271
function dasherize(str) {
  return str.replace(
      /([a-z])([A-Z])/g,
    (_, let1, let2) => `${let1}-${let2.toLowerCase()}`
  );
}
1351576
function normalize(value, options) {
  var settings = options || {}
  var allowApostrophes = settings.allowApostrophes
  var allowDashes = settings.allowDashes
  var result = (typeof value === 'string' ? value : toString(value))
    .toLowerCase()
    .replace(APOSTROPHE, QUOTE)

  if (allowApostrophes && allowDashes) {
    return result
  }

  if (allowApostrophes) {
    return result.replace(DASH, EMPTY)
  }

  if (allowDashes) {
    return result.replace(QUOTE, EMPTY)
  }

  return result.replace(ALL, EMPTY)
}
273770
def ansiformat(attr, text):
    
    result = []
    if attr[:1] == attr[-1:] == '+':
        result.append(codes['blink'])
        attr = attr[1:-1]
    if attr[:1] == attr[-1:] == '*':
        result.append(codes['bold'])
        attr = attr[1:-1]
    if attr[:1] == attr[-1:] == '_':
        result.append(codes['underline'])
        attr = attr[1:-1]
    result.append(codes[attr])
    result.append(text)
    result.append(codes['reset'])
    return ''.join(result)
1030524
private String replacePosixClasses(String input) {
        return input
            .replace(":alnum:", "\\p{Alnum}")
            .replace(":alpha:", "\\p{L}")
            .replace(":ascii:", "\\p{ASCII}")
            .replace(":digit:", "\\p{Digit}")
            .replace(":xdigit:", "\\p{XDigit}");
    }
14531
public static String cleanupStr(String name, boolean allowDottedKeys) {
		if (name == null) {
			return null;
		}
		Pattern pattern;
		if (!allowDottedKeys) {
			pattern = DOT_SLASH_UNDERSCORE_PAT;
		} else {
			pattern = SLASH_UNDERSCORE_PAT;
		}
		String clean = pattern.matcher(name).replaceAll("_");
		clean = SPACE_PAT.matcher(clean).replaceAll("");
		clean = org.apache.commons.lang.StringUtils.chomp(clean, ".");
		clean = org.apache.commons.lang.StringUtils.chomp(clean, "_");
		return clean;
	}
535708
def validate_ok_for_replace(replacement):
    """"""
    validate_is_mapping("replacement", replacement)
    # Replacement can be {}
    if replacement and not isinstance(replacement, RawBSONDocument):
        first = next(iter(replacement))
        if first.startswith('$'):
            raise ValueError('replacement can not include $ operators')
1209628
def tmpl_alphanum(self, text):
        
        text = self.tmpl_asciify(text)
        text = re.sub(r'[^a-zA-Z0-9]+', ' ', text)
        return re.sub(r'\s+', ' ', text)
1185210
def alphanum_key(string):
    
    convert = lambda text: int(text) if text.isdigit() else text
    return [convert(segment) for segment in re.split('([0-9]+)', string)]
1272724
private static String sanitizeName(String name) {
        StringBuilder ret = new StringBuilder();
        int underscores = 0;
        boolean lastWasADot = false;
        for (char c : name.toCharArray()) {
            if (c == '_') {
                underscores++;
                // Only _ in a row are allowed
                if (underscores <= 2) {
                    ret.append(c);
                }
                continue;
            }

            if (c == '.') {
                // Only one dot in a row is allowed
                if (!lastWasADot) {
                    ret.append(c);
                }
                lastWasADot = true;
                continue;
            }

            underscores = 0;
            lastWasADot = false;
            if (Character.isLetter(c) || Character.isDigit(c) || c == '-') {
                ret.append(c);
            }
        }

        // All characters must be lowercase
        return ret.toString().toLowerCase();
    }
373556
def slugify(cls, s):
        """"""
        slug = re.sub("[^0-9a-zA-Z-]", "-", s)
        return re.sub("-{2,}", "-", slug).strip('-')
578698
def _remove_invalid_char(s):
    """"""

    s = ''.join([i if ord(i) >= 32 and ord(i) < 127 else '' for i in s])
    s = s.translate(dict.fromkeys(map(ord, "_%~#\\{}\":")))
    return s
1080943
def underscore_string(str)
        str.to_s.strip.
          gsub(' ', '_').
          gsub(/::/, '/').
          gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
          gsub(/([a-z\d])([A-Z])/,'\1_\2').
          tr("-", "_").
          squeeze("_").
          downcase
      end