Format a value e.g :region, 'NY'
 apply any formatting rules
  - if rule fullname included change the region to it's full name - New York
 options = ignore_rules: ['upcase']
764321
def format_values(field, value, options={})
      value = value.dup
      value.to_s.strip!
      if !fields.key?(field) || fields[field][:format].nil?
        return value
      end
      rules = fields[field][:format].dup
      # ignore rules
      if options[:ignore_rules]
        rules = rules - options[:ignore_rules]
      end
      # use fullname rather than abbreviated
      # fullname rule must be applied first!
      if rules.delete('fullname') && regions[value]
        value = regions[value]
      end
      # formatting
      rules.each do |rule|
        case rule
        when 'upcase'
          value.upcase!
        end
      end
      value
    end
836072
function formatStr(str, values) {
    values = values || {};

    if (typeof str !== 'string') {
        return str;
    }

    return str.replace(FORMAT_REGEXP, (m0, m1, m2) => (m1 === '%' ? "%{" + m2 + "}" : values[m2]));
}
591222
def _apply_common_rules(self, part, maxlength):
        
        part = part.strip()
        
        if self.fix:
            part = part.strip('.')
        
        if not part:
            return part, 'It cannot be empty.'
        
        if len(part) > maxlength:
            return part, 'It cannot be longer than %i chars.' % maxlength
        
        if part[0] == '.':
            return part, 'It cannot start with a dot.'
        
        if part[-1] == '.':
            return part, 'It cannot end with a dot.'
        
        if '..' in part:
            return part, 'It cannot contain consecutive dots.'
        
        return part, ''
1164653
protected void applyHiddenRegionFormatting(List<ITextReplacer> replacers) {
		IHiddenRegionFormatting separator = findWhitespaceThatSeparatesSemanticRegions(replacers).getFormatting();

		// 1. apply indentation 
		Integer inc = formatting.getIndentationIncrease();
		Integer dec = formatting.getIndentationDecrease();
		if (inc != null && dec != null) {
			((WhitespaceReplacer) replacers.get(0)).getFormatting().setIndentationIncrease(inc);
			((WhitespaceReplacer) replacers.get(replacers.size() - 1)).getFormatting().setIndentationDecrease(dec);
		} else if (inc != null) {
			separator.setIndentationIncrease(inc);
		} else if (dec != null) {
			separator.setIndentationDecrease(dec);
		}

		// 2. apply NewLine and space configuration to the first whitespace region that follows or contains a linewrap.  
		separator.setNewLinesDefault(formatting.getNewLineDefault());
		separator.setNewLinesMax(formatting.getNewLineMax());
		separator.setNewLinesMin(formatting.getNewLineMin());
		separator.setSpace(formatting.getSpace());

		// 3. apply the 'priority' configuration for all and set a default formatting
		for (ITextReplacer replacer : replacers)
			if (replacer instanceof WhitespaceReplacer) {
				IHiddenRegionFormatting formatting2 = ((WhitespaceReplacer) replacer).getFormatting();
				formatting2.setPriority(formatting.getPriority());
				if (formatting2 != separator) {
					formatting2.setSpace(replacer.getRegion().getOffset() > 0 ? " " : "");
					formatting2.setNewLinesMin(0);
					formatting2.setNewLinesMax(1);
				}
			}

		// 4. make sure whitespace before and after multiline comments introduce a NewLine 
		for (int i = 0; i < replacers.size(); i++) {
			ITextReplacer replacer = replacers.get(i);
			if (replacer instanceof CommentReplacer) {
				CommentReplacer commentReplacer = ((CommentReplacer) replacer);
				WhitespaceReplacer leading = (WhitespaceReplacer) replacers.get(i - 1);
				WhitespaceReplacer trailing = (WhitespaceReplacer) replacers.get(i + 1);
				commentReplacer.configureWhitespace(leading, trailing);
			}
		}
	}
625743
def acceptable(value, capitalize=False):
    """"""
    name = regexes['punctuation'].sub("", regexes['joins'].sub("_", value))
    # Clean up irregularities in underscores.
    name = regexes['repeated_underscore'].sub("_", name.strip('_'))
    if capitalize:
        # We don't use python's built in capitalize method here because it
        # turns all upper chars into lower chars if not at the start of
        # the string and we only want to change the first character.
        name_parts = []
        for word in name.split('_'):
            name_parts.append(word[0].upper())
            if len(word) > 1:
                name_parts.append(word[1:])
        name = ''.join(name_parts)
    return name
1023437
def convert_case(name):
        """"""
        s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
        return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
823935
def set_rule_option(self, rule_name_or_id, option_name, option_value):
        
        option = self._get_option(rule_name_or_id, option_name)
        try:
            option.set(option_value)
        except options.RuleOptionError as e:
            msg = u"'{0}' is not a valid value for option '{1}.{2}'. {3}."
            raise LintConfigError(msg.format(option_value, rule_name_or_id, option_name, ustr(e)))
329880
function(_string, _locale) {
            var rules = loadRulesFor(_locale);
            return rules ? applyRules(_string, rules.singular, rules.uncountable) : _string;
          }
2896
function applyRules(_string, _ruleSet, _skip) {

      if(_skip.indexOf(_string.toLowerCase()) === -1) {
        var i = 0, rule;
        while(rule = _ruleSet[i++]) {
          if(_string.match(rule[0])) {
            return _string.replace(rule[0], rule[1]);
          }
        }
      }

      return _string;
    }
362724
function inflect(gender, name, gcase, nametype) {
        var nametype_rulesets = rules[nametype],
            parts = name.split('-'),
            result = [];
        for (var i = 0; i < parts.length; i++) {
            var part = parts[i], first_word = i === 0 && parts.size > 1,
                rule = find_rule_global(gender, part,
                    nametype_rulesets, {first_word: first_word});
            if (rule) result.push(apply_rule(part, gcase, rule));
            else result.push(part);
        }
        return result.join('-');
    }
356291
def title_slug
      value = (@options['slug'] || @options['title']).downcase
      value.gsub!(/[^\x00-\x7F]/u, '')
      value.gsub!(/(&amp;|&)+/, 'and')
      value.gsub!(/[']+/, '')
      value.gsub!(/\W+/, ' ')
      value.strip!
      value.gsub!(' ', '-')
      value
    end
646280
def format_field_by_match(self, value, match):
        """"""
        groups = match.groups()
        fill, align, sign, sharp, zero, width, comma, prec, type_ = groups
        if not comma and not prec and type_ not in list('fF%'):
            return None
        if math.isnan(value) or math.isinf(value):
            return None
        locale = self.numeric_locale
        # Format number value.
        prefix = get_prefix(sign)
        if type_ == 'd':
            if prec is not None:
                raise ValueError('precision not allowed in '
                                 'integer format specifier')
            string = format_number(value, 0, prefix, locale)
        elif type_ in 'fF%':
            format_ = format_percent if type_ == '%' else format_number
            string = format_(value, int(prec or DEFAULT_PREC), prefix, locale)
        else:
            # Don't handle otherwise.
            return None
        if not comma:
            # Formatted number always contains group symbols.
            # Remove the symbols if not required.
            string = remove_group_symbols(string, locale)
        if not (fill or align or zero or width):
            return string
        # Fix a layout.
        spec = ''.join([fill or u'', align or u'>',
                        zero or u'', width or u''])
        return format(string, spec)
981497
def format_property(name, value):
    """"""
    result = b''
    utf8_name = utf8_bytes_string(name)

    result = b'property ' + utf8_name
    if value is not None:
        utf8_value = utf8_bytes_string(value)
        result += b' ' + ('%d' % len(utf8_value)).encode('ascii') + b' ' + utf8_value

    return result
766134
def _format_default(client, value):
    """"""
    if isinstance(value, File):
        return os.path.relpath(
            str((client.workflow_path / value.path).resolve())
        )
    return value
185532
function getPascalCase(val) {
        var parts = val.split('.');
        var newVal = '';

        for (var i = 0; i < parts.length; i++) {
            newVal += parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1);
        }

        return newVal;
    }
1183047
def format_value(self, value, padding):
        """"""

        # padding = padding - 1 if value < 0 and padding > 0 else padding
        # prefix = '-' if value < 0 else ''

        if padding:
            return "{:0{pad}d}".format(value, pad=padding)

        else:
            return str(value)
1026773
def init_rule(rule_name)
    rule_name.to_s[/^([^?!]*)([?!])?$/]
    rule_name = $1.to_sym
    option = $2
    match_rule = rules[rule_name]
    raise "no rule for #{rule_name}" unless match_rule

    self.parser = lambda {|parent_node| match_rule.parse(parent_node)}
    self.name ||= rule_name
    case option
    when "?"  then self.optional = true
    when "!"  then self.negative = true
    end
  end