/*
Create the Prometheus metric name by sanitizing some characters
3230
private static String getPrometheusMetricName(String name) {

        String out = name.replaceAll("(?<!^|:)(\\p{Upper})(?=\\p{Lower})", "_$1");
        out = out.replaceAll("(?<=\\p{Lower})(\\p{Upper})", "_$1").toLowerCase();
        out = out.replaceAll("[-_.\\s]+", "_");
        out = out.replaceAll("^_*(.*?)_*$", "$1");

        return out;
    }
972410
public static String sanitizeName(String name) {

        if (name  == null)
            throw new NullPointerException("Parameter name cannot be null");

        name = name.trim();

        if (name.length() == 0)
            throw new IllegalArgumentException("Parameter name cannot be empty");

        StringBuilder ret = new StringBuilder("");

        for (int i = 0; i < name.length(); i++) {
            char ch = name.charAt(i);
            if (Character.isLetter(ch) || Character.isDigit(ch)) {
                ret.append(ch);
            } else {
                ret.append("_");
            }

        }

        return ret.toString();
    }
750324
private static String sanitizeString(final String in) {
    String result = null;
    if (in != null) {
      result = in.replace(':', '_');
      result = result.replace('/', '_');
      result = result.replace('\\', '_');
    }
    return result;
  }
815945
def nameify(self, camelsplit=False, ascii=True, sep='-'):
        """"""
        s = String(str(self))  # immutable
        if camelsplit == True:
            s = s.camelsplit()
        s = s.hyphenify(ascii=ascii).replace('-', sep)
        if len(s) == 0 or re.match("[A-Za-z_]", s[0]) is None:
            s = "_" + s
        return String(s)
440544
public static String sanitize (String source, CharacterValidator validator)
    {
        if (source == null) {
            return null;
        }
        int nn = source.length();
        StringBuilder buf = new StringBuilder(nn);
        for (int ii=0; ii < nn; ii++) {
            char c = source.charAt(ii);
            if (validator.isValid(c)) {
                buf.append(c);
            }
        }
        return buf.toString();
    }
1066545
def _sanitize(self, unsanitized):
        

        sanitized = ""

        # strip punctuation and diacritics
        replace_punct = str.maketrans( string.punctuation + "᾽᾿῾", ' '*(len(string.punctuation) + 3)  )
        sanitized = unsanitized.translate( replace_punct )
        sanitized = "".join(c for c in unicodedata.normalize("NFD", sanitized) if unicodedata.category(c) != "Mn")

        #finally, lose all whitespace
        sanitized = re.sub(r'\s+','', sanitized)

        return sanitized
95680
def sanitized_name(self):
        
        a = re.split("[:/]", self.name)
        return "_".join([i for i in a if len(i) > 0])
92624
@Override
    public String name(String name, Meter.Type type, @Nullable String baseUnit) {
        String sanitizedName = NAME_CLEANUP_PATTERN.matcher(delegate.name(name, type, baseUnit)).replaceAll("_");

        // add name prefix if prefix exists
        if (namePrefix != null) {
            return namePrefix + "." + sanitizedName;
        }
        return sanitizedName;
    }
60432
@Override
    public String name(String name, Meter.Type type, @Nullable String baseUnit) {
        String conventionName = NamingConvention.snakeCase.name(name, type, baseUnit);

        switch (type) {
            case COUNTER:
            case DISTRIBUTION_SUMMARY:
            case GAUGE:
                if (baseUnit != null && !conventionName.endsWith("_" + baseUnit))
                    conventionName += "_" + baseUnit;
                break;
        }

        switch (type) {
            case COUNTER:
                if (!conventionName.endsWith("_total"))
                    conventionName += "_total";
                break;
            case TIMER:
            case LONG_TASK_TIMER:
                if (conventionName.endsWith(timerSuffix)) {
                    conventionName += "_seconds";
                } else if (!conventionName.endsWith("_seconds"))
                    conventionName += timerSuffix + "_seconds";
                break;
        }

        String sanitized = nameChars.matcher(conventionName).replaceAll("_");
        if (!Character.isLetter(sanitized.charAt(0))) {
            sanitized = "m_" + sanitized;
        }
        return sanitized;
    }
731367
public static String sanitizeBuildName(String buildName) {
        String s = StringUtils.replace(buildName, "/", " :: ");
        return StringUtils.replace(s, "%2F", " :: ");
    }
646485
static String generateFullMetricDescription(String metricName, Metric metric) {
    return "Collected from "
        + SOURCE
        + " (metric="
        + metricName
        + ", type="
        + metric.getClass().getName()
        + ")";
  }
289635
private static String sanitizeName(String name) {
		final String lowerCaseName = name.toLowerCase(Locale.US);
		final String separatorReplacedName = SANITIZE_TO_UNDERSCORE_PATTERN.matcher(lowerCaseName)
				.replaceAll(UNDERSCORE);
		return SANITIZE_REMOVE_PATTERN.matcher(separatorReplacedName).replaceAll(EMPTY_STRING);
	}
637001
protected String normalizeName(String originalName) {
        if (originalName == null || originalName.endsWith(".js")) {
            return originalName;
        }
        return originalName + ".js";
    }
1080908
function directiveNormalize(name) {
      return name
        .replace(PREFIX_REGEXP, '')
        .replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
          return offset ? letter.toUpperCase() : letter;
        });
    }
246428
def _normalize_custom_param_name(name):
    

    replacements = (("\u2018", "'"), ("\u2019", "'"), ("\u201C", '"'), ("\u201D", '"'))
    for orig, replacement in replacements:
        name = name.replace(orig, replacement)
    return name
1322857
private static String cleanDocumentation(String comment, Iterable<String> sourceParameters, Iterable<String> targetParameters) {
		String clean = comment;
		if (!Strings.isNullOrEmpty(clean)) {
			final Set<String> parameterNames = new TreeSet<>();
			if (sourceParameters != null) {
				for (final String param : sourceParameters) {
					parameterNames.add(param);
				}
			}
			if (targetParameters != null) {
				for (final String param : targetParameters) {
					parameterNames.remove(param);
				}
			}
			for (final String parameterName : parameterNames) {
				clean = clean.replaceFirst(
					"\\Q@param\\E\\s+\\Q" + parameterName + "\\E\\s*", //$NON-NLS-1$//$NON-NLS-2$
					"@optionalparam " + parameterName + " "); //$NON-NLS-1$//$NON-NLS-2$
			}
		}
		return clean;
	}
1020089
protected static void checkMetricLabelName(String name) {
    if (!METRIC_LABEL_NAME_RE.matcher(name).matches()) {
      throw new IllegalArgumentException("Invalid metric label name: " + name);
    }
    if (RESERVED_METRIC_LABEL_NAME_RE.matcher(name).matches()) {
      throw new IllegalArgumentException("Invalid metric label name, reserved for internal use: " + name);
    }
  }