Converts a string and its placeholders to plain text.
559184
function(actor, target, vars) {

		var a = {
			name: actor.get('definite'),
			gender: actor.gender
		};

		var t = {};
		if (target) {
			t.name = target.get('definite');
			t.gender = target.get('gender');
		} else {
			t.name = 'NULL';
			t.gender = 0;
		}

		var pronouns = {
			sub:  ['it', 'he', 'she'],
			obj:  ['it', 'him', 'her'],
			pos:  ['its', 'his', 'her'],
			ref:  ['itself', 'himself', 'herself'],
			hers: ['its', 'his', 'hers']
		};

		Object.each(pronouns, function(v,k) {
			a[k] = v[a.gender] || v[0];
			if (target) { t[k] = v[t.gender] || v[0]; }
		});

		//Replacements: what the actor sees and what the target sees.
		var actor_tags = {
			'You'      : ['You',      a.name],
			"yourself" : ["yourself", a.ref],
			"your"     : ["your",     a.pos],
			'you'      : ['you',      a.sub],
			'thee'     : ['you',      a.obj],
			"yours"    : ["yours",    a.hers],
			"Your"     : ["Your",     a.name+"'s"],
			'has'      : ['have',     'has'],
			'is'       : ['are',      'is']
		};

		var target_tags = {
			'Name'     : ['You',      t.name],
			'They'     : ['You',      t.name],
			'Name'     : ['you',      t.name],
			'they'     : ['you',      t.sub],
			'them'     : ['you',      t.obj],
			"theirs"   : ["yours",    t.hers],
			"their"    : ["your",     t.pos],
			"Their"    : ["your",     t.name+"'s"],
			"themself" : ["yourself", t.ref],
			'HAS'      : ['have',     'has'],
			'IS'       : ['are',      'is']
		};

		var actor_suffixes = {
			's'        : ['', 's'],
			'es'       : ['', 'es'],
			'ies'      : ['y', 'ies'],
			"'s"       : ["'re'", "'s"]
		};

		var target_suffixes = {
			'S'        : ['', 's'],
			'ES'       : ['', 'es'],
			'IES'      : ['y', 'ies'],
			"'S"       : ["'re", "'s"]
		};

		var str = this, str_actor = this, str_target=this, str_others=this;

		Object.each(actor_suffixes, function(replace, tag) {
			var tag = new RegExp('%'+tag+'(\\s?)', 'g');
			if (!str.match(tag)) { return; }
			str_actor  = str_actor.replace(tag, replace[0]+"$1");
			if (target) {
				str_target = str_target.replace(tag, replace[1]+"$1");
			}
			str_others = str_others.replace(tag, replace[1]+"$1");
		});

		Object.each(actor_tags, function(replace, tag) {
			var tag = new RegExp('%'+tag+'(\\s?)', 'g');
			if (!str.match(tag)) { return; }
			str_actor  = str_actor.replace(tag, replace[0]+"$1");
			if (target) {
				str_target = str_target.replace(tag, replace[1]+"$1");
			}
			str_others = str_others.replace(tag, replace[1]+"$1");
		});

		//No need to waste time processing target tags if there's no target.
		if (target) {

			Object.each(target_suffixes, function(replace, tag) {
				var tag = new RegExp('%'+tag+'(\\s?)', 'g');
				if (!str.match(tag)) { return; }
				str_actor  = str_actor.replace(tag, replace[1]+"$1");
				if (target) {
					str_target = str_target.replace(tag, replace[0]+"$1");
				}
				str_others = str_others.replace(tag, replace[1]+"$1");
			});

			Object.each(target_tags, function(replace, tag) {
				var tag = new RegExp('%'+tag+'(\\s?)', 'g');
				if (!str.match(tag)) { return; }
				str_actor  = str_actor.replace(tag, replace[1]+"$1");
				if (target) {
					str_target = str_target.replace(tag, replace[0]+"$1");
				}
				str_others = str_others.replace(tag, replace[1]+"$1");
			});

		} else {
			str_target = str_others;
		}

		strs = [str_actor, str_target, str_others];

		//Auto-capitaliztion
		strs.each(function(str, i) {
			var matches = str.match(/[\.\?!]\s+[a-z]/);
			if (!matches) { return; }
			matches.each(function(m) {
				strs[i] = str.replace(m, m.toUpperCase());
			});
		});
	
		return strs;

	}
922126
private static String property(String string) {
        int length = string.length();

        if (length == 0) {
            return "";
        }
        else if (length == 1) {
            return string.toLowerCase();
        }
        else {
            return string.substring(0, 1).toLowerCase() + string.substring(1);
        }
    }
855442
def tokenize_string(cls, string, separator):
        """"""
        results = []
        token = ""
        found_escape = False
        for c in string:
            if found_escape:
                if c == separator:
                    token += separator
                else:
                    token += "\\" + c
                found_escape = False
                continue
            if c == "\\":
                found_escape = True
            elif c == separator:
                results.append(token)
                token = ""
            else:
                token += c

        results.append(token)
        return results
440265
def __convert_string(node):
    """"""
    converted = __convert_node(node, default_flags=vsflags(VSFlags.UserValue))

    return __check_for_flag(converted)
654733
def fromstring(cls, string):
        
        parser = etree.XMLParser(remove_blank_text=True)
        root = etree.fromstring(string, parser)
        tree = root.getroottree()

        return cls.fromtree(tree)
676359
function replacePlaceholders(src, options) {
	return Object.keys(placeholders).reduce((out, placeholder) => {
		return out.replace(new RegExp(`${placeholder}`, 'g'), placeholders[placeholder]);
	}, src);
}
100416
private String trim(String string) {

		while (string.startsWith("\"") && string.endsWith("\"")) {

			string = string.substring(1, string.length() - 1);
		}
		return string;
	}
695838
private static String cleanText(String strText) {
        strText = HTMLParser.unsafeRemoveAllTags(strText);
        strText = strText.toLowerCase(Locale.ENGLISH);
        
        strText = StringCleaner.unifyTerminators(strText);
        
        strText = strText.replaceAll(" [0-9]+ ", " "); // Remove "words" comprised only of numbers
        
        strText = StringCleaner.removeExtraSpaces(strText);
        return strText;
    }
18839
def tokenize(self, string):
        """"""
        it = colorise.compat.ifilter(None, self._pattern.finditer(string))

        try:
            t = colorise.compat.next(it)
        except StopIteration:
            yield string, False
            return

        pos, buf, lm, escapeflag = -1, '', -1, False

        # Check if we need to yield any starting text
        if t.start() > 0:
            yield string[:t.start()], False
            pos = t.start()

        it = itertools.chain([t], it)

        for m in it:
            start = m.start()
            e, s = m.group(2) or '', m.group(3)
            escaped = e.count(self._ESCAPE) % 2 != 0

            if escaped:
                buf += string[pos:m.end(2)-1] + s
                escapeflag = True
            else:
                buf += string[pos:m.start(3)]

                if buf:
                    yield buf, escapeflag
                    buf = ''
                    escapeflag = False

                if lm == start:
                    yield '', False

                yield s, False
                lm = m.end()

            pos = m.end()

        if buf:
            yield buf, escapeflag
            escapeflag = False

        if pos < len(string):
            yield string[pos:], False
87669
private static String cleanString(String str)
    {
	String result = str;
	result = result.replace("\r", "");
	result = result.replace("\n", "");
	result = result.replace("\t", "");

	return result;
    }
1003949
static String convertFromHtml(final String textToConvert) {

        //LinkedHashmap since the order matters
        final Map<String, String> regexps = new LinkedHashMap<>();

        regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)</ *a *>","$2 ($1)");
        regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)< *a */>","$2 ($1)");
        regexps.put("</ *(br|p|table|h[1-4]|pre|hr|li|ul) *>","\n");
        regexps.put("< *(br|p|table|h[1-4]|pre|hr|li|ul) */>","\n");
        regexps.put("< *(p|table|h[1-4]|ul|pre) *>","\n");
        regexps.put("<li>", " - ");
        regexps.put("</th>", "\t");
        regexps.put("<\\w*?>", "");

        return regexps.entrySet().stream().sequential()
                .reduce(textToConvert, (string, entrySet) -> string.replaceAll(entrySet.getKey(), entrySet.getValue()), (a, b) -> b);
    }
541288
def from_string(self, value):
        """"""
        # Remove optional {}
        if value.startswith('{') and value.endswith('}'):
            text = value[1:-1].strip()
        else:
            text = value.strip()
        # Result is a dictionary
        result = {}
        # Convert each pair of <int>:<float> into a key, value pair.
        for val in text.split(','):
            tokens = val.split(':')
            if len(tokens) != 2:
                raise ValueError('invalid entry in dictionary: ' + val)
            result[str(int(tokens[0].strip()))] = float(tokens[1].strip())
        return result
369190
def clean_whitespace(string, compact=False):
    """"""
    for a, b in (('\r\n', '\n'), ('\r', '\n'), ('\n\n', '\n'),
                 ('\t', ' '), ('  ', ' ')):
        string = string.replace(a, b)
    if compact:
        for a, b in (('\n', ' '), ('[ ', '['),
                     ('  ', ' '), ('  ', ' '), ('  ', ' ')):
            string = string.replace(a, b)
    return string.strip()
1139225
def wrap_str_of(self, text):
        """"""
        text_repr = ascii(text)
        internal_assert(text_repr[0] == text_repr[-1] and text_repr[0] in ("'", '"'), "cannot wrap str of", text)
        return self.wrap_str(text_repr[1:-1], text_repr[-1])
813732
def preprocess(string):
    
    string = unicode(string, encoding="utf-8")
    return regex.sub('', string).encode('utf-8')
1235275
private String cleanUpString(String text) {
    if (StringUtils.isEmpty(text)) {
      return text;
    }
    else {
      return CONTROL_CHARS.matcher(text).replaceAll("");
    }
  }
528319
private static String trim(String string) {
        String result = string.trim();
        if (result.startsWith("\"") && result.endsWith("\"") && result.length() > 1) {
            result = result.substring(1, result.length() - 1);
        }
        return result;
    }