returns the number of anchors {} in a string

@param formatString
the format string
@return the number of anchors
439530
private static int countAnchors(String formatString) {
        Matcher m = FORMATTER_ANCHOR.matcher(formatString);
        int count = 0;
        int start = 0;
        while (m.find(start)) {
            ++count;
            start = m.end();
        }

        return count;
    }
704142
public static String formatDateString(String dateString, String format1, String format2) {
        if (dateString == null) {
            return null;
        }
        java.text.SimpleDateFormat beforeFormat = new java.text.SimpleDateFormat(format1);
        java.text.SimpleDateFormat endFormat = new java.text.SimpleDateFormat(format2);
        try {
            return endFormat.format(beforeFormat.parse(dateString));
        } catch (ParseException e) {
            e.printStackTrace();
            return dateString;
        }
    }
1275752
public String getFormatString(int formatIndex) {
        String format = null;
        if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
            FormatRecord tfr = _customFormatRecords.get(Integer.valueOf(formatIndex));
            if (tfr == null) {
                logger.log(POILogger.ERROR, "Requested format at index " + formatIndex
                    + ", but it wasn't found");
            } else {
                format = tfr.getFormatString();
            }
        } else {
            format = HSSFDataFormat.getBuiltinFormat((short) formatIndex);
        }
        return format;
    }
440301
private String convertString(String str, String format, String expr)
    {
        String ret = str;

        String[] params = null;
        if(format.length() > 0)
        {
            ret = "";
            if(expr.length() > 0) // Indicates a format using regex
            {

                Pattern pattern = getPattern(expr);
                Matcher m = pattern.matcher(str);
                if(m.find())
                {
                    params = new String[m.groupCount()];
                    for(int i = 0; i < m.groupCount(); i++)
                        params[i] = m.group(i+1);
                }
            }
            else if(str != null)
            {
                params = new String[]{str};
            }

            if(params != null)
                ret = String.format(format, params);
        }

        return ret;
    }
1056522
String getFormattedArray(Object attribute, String indent) {
        int arrayLength = Array.getLength(attribute);
        if (arrayLength == 0) {
            return "[]";
        }

        Class<?> componentType = attribute.getClass().getComponentType();

        // For the 8 primitive types, a cast is necessary when invoking
        // Arrays.toString.  The array data is then broken into separate
        // lines
        if (componentType.equals(boolean.class)) {
            return formatPrimitiveArrayString(Arrays.toString((boolean[]) attribute), indent);
        } else if (componentType.equals(byte.class)) {
            return formatPrimitiveArrayString(Arrays.toString((byte[]) attribute), indent);
        } else if (componentType.equals(char.class)) {
            return formatPrimitiveArrayString(Arrays.toString((char[]) attribute), indent);
        } else if (componentType.equals(double.class)) {
            return formatPrimitiveArrayString(Arrays.toString((double[]) attribute), indent);
        } else if (componentType.equals(float.class)) {
            return formatPrimitiveArrayString(Arrays.toString((float[]) attribute), indent);
        } else if (componentType.equals(int.class)) {
            return formatPrimitiveArrayString(Arrays.toString((int[]) attribute), indent);
        } else if (componentType.equals(long.class)) {
            return formatPrimitiveArrayString(Arrays.toString((long[]) attribute), indent);
        } else if (componentType.equals(short.class)) {
            return formatPrimitiveArrayString(Arrays.toString((short[]) attribute), indent);
        }

        // Arbitrary strings can have ', ' in them so we iterate here
        StringBuilder sb = new StringBuilder();
        indent += INDENT;

        Object[] array = (Object[]) attribute;
        for (int i = 0; i < array.length; i++) {
            sb.append("\n").append(indent).append("[").append(i).append("]: ");
            sb.append(String.valueOf(array[i]));
        }
        return sb.toString();
    }
298144
function formatString(string, params) {
  return string.replace(/{(\d+)}/g, function (match, number) {
    return typeof params[number] !== undefined ? params[number] : match;
  });
}
1268135
private FormatString[] parse(String s) {
        ArrayList<FormatString> al = new ArrayList<>();
        for (int i = 0, len = s.length(); i < len; ) {
            int nextPercent = s.indexOf('%', i);
            if (s.charAt(i) != '%') {
                // This is plain-text part, find the maximal plain-text
                // sequence and store it.
                int plainTextStart = i;
                int plainTextEnd = (nextPercent == -1) ? len: nextPercent;
                al.add(new FixedString(s.substring(plainTextStart,
                                                   plainTextEnd)));
                i = plainTextEnd;
            } else {
                // We have a format specifier
                FormatSpecifierParser fsp = new FormatSpecifierParser(s, i + 1);
                al.add(fsp.getFormatSpecifier());
                i = fsp.getEndIdx();
            }
        }
        return al.toArray(new FormatString[al.size()]);
    }
288280
function getWidth(stringWidth, str) {
	if (!stringWidth || !stringWidth.toLowerCase)
		return str.length;
	switch (stringWidth.toLowerCase()) {
		case "wcwidth":
			return wcwidth(str);
		case "dbcs":
			return dbcswidth(str);
		case "length":
			return str.length;
		default:
			return str.length;
	}
}
709689
private static final boolean isNumeric(char formatChar, int count) {
        return NUMERIC_FORMAT_CHARS.indexOf(formatChar) >= 0
                || (count <= 2 && NUMERIC_FORMAT_CHARS2.indexOf(formatChar) >= 0);
    }
269682
def get_tokens(self, format_string):
        
        return [t for t in self.tokenize_pattern.split(format_string) if t]
885294
private static String translateFormat(String formatString, Map<String, String> mapping, String escapeStart, String escapeEnd, String targetEscapeStart, String targetEscapeEnd) {
		int beginIndex = 0;
		int i = 0;
		char lastChar = 0;
		char currentChar = 0;
		String resultString = "";
		char esc1 = escapeStart.charAt(0);
		char esc2 = escapeEnd.charAt(0);

		for (; i < formatString.length(); i++) {
			currentChar = formatString.charAt(i);
			if (i > 0 && lastChar != currentChar) {
				resultString += mapSubformat(formatString, mapping, beginIndex, i, escapeStart, escapeEnd, targetEscapeStart, targetEscapeEnd);
				beginIndex = i;
			}
			lastChar = currentChar;
			if (currentChar == esc1) {
				i++;
				while (i< formatString.length() && formatString.charAt(i) != esc2) {
					i++;
				}
				resultString += targetEscapeStart;
				resultString += formatString.substring(beginIndex+1, i);
				resultString += targetEscapeEnd;
				i++;
				if (i < formatString.length()) {
					lastChar = formatString.charAt(i);
				}
				beginIndex = i;
			}
		}
		
		if (beginIndex < formatString.length() && i <= formatString.length()) {
			return resultString + mapSubformat(formatString, mapping, beginIndex, i, escapeStart, escapeEnd, targetEscapeStart, targetEscapeEnd);
		} else {
			return resultString;
		}

	}
935516
public static String getDigitsFromHexLiteral(String paramString) {
        Matcher matcher = SingleQuotedHexLiteral.matcher(paramString);
        if (matcher.matches()) {
            return matcher.group(1);
        }
        return null;
    }
844028
function translateFormat(formatString, mapping) {
  let len = formatString.length,
    i = 0,
    beginIndex = -1,
    lastChar = null,
    currentChar = "",
    resultString = "";

  for (; i < len; i++) {
    currentChar = formatString.charAt(i);

    if (lastChar === null || lastChar !== currentChar) {
      // change detected
      resultString = _appendMappedString(formatString, mapping, beginIndex, i, resultString);

      beginIndex = i;
    }

    lastChar = currentChar;
  }

  return _appendMappedString(formatString, mapping, beginIndex, i, resultString);
}
542088
def get_pairs(self, format_string):
        
        for token in self.get_tokens(format_string):
            match = self.name_pattern.search(token)
            name = match.group(1) if match else None
            yield FormatStringToken(name=name, text=token)
532974
public static <T extends Number> String str(T x, DecimalFormat formatter) {
        if (Double.isNaN(x.doubleValue())) {
            return "nan";
        }
        if (Double.isInfinite(x.doubleValue())) {
            return isLt(x.doubleValue(), 0.0) ? "-inf" : "inf";
        }
        return formatter.format(x);
    }
519491
function formatString (string) {
    const separator = "\n";
    return Array.isArray(string) ?
        string.reduce((acc, line) => acc.concat(line.split(separator)), []) :
        string.split(separator);
}
50506
public static String format_location(EvaluationContext ctx, Object text) {
        String _text = Conversions.toString(text, ctx);
        String[] splits = _text.split(">");
        return splits[splits.length - 1].trim();
    }