Trim double quotes off the ends of a value, un-escaping inner
        double quotes and literal backslashes. Also convert escapes to unicode.
        If the string is not quoted, return it unmodified.
13466
def _trim_value(self, value):
        

        if value[0] == '"':
            assert value[-1] == '"'
            value = value[1:-1].replace('\\"', '"').replace("\\\\", "\\")
            return Parser._unescape_re.sub(Parser._unescape_fn, value)
        return value
450989
function trimStringEnds(keyValueString, unwantedCharArray) {
    var unwantedBegCharIndex = 0;
    var unwantedEndCharIndex = keyValueString.length - 1;
    var charIsUnwanted;
    var keepGoing = true; //keep traversing the string
    //starting from the beginning of the string
    while (keepGoing) {
        charIsUnwanted = false;
        for (var x = 0; x < unwantedCharArray.length; x++) {
            if (keyValueString.charAt(unwantedBegCharIndex) === unwantedCharArray[x]) {
                charIsUnwanted = true;
            }
        }
        if (!charIsUnwanted) {
            keepGoing = false;
        } else {
            unwantedBegCharIndex++;
        }
    }
    //now start at the end
    keepGoing = true;
    while (keepGoing) {
        charIsUnwanted = false;
        for (var y = 0; y < unwantedCharArray.length; y++) {
            if (keyValueString.charAt(unwantedEndCharIndex) === unwantedCharArray[y]) {
                charIsUnwanted = true;
            }
        }
        if (!charIsUnwanted) {
            keepGoing = false;
        } else {
            unwantedEndCharIndex--;
        }
    }
    keyValueString = keyValueString.slice(unwantedBegCharIndex, unwantedEndCharIndex + 1);
    return keyValueString;
}
892771
def _trim(self, somestr):
        
        tmp = RE_LSPACES.sub("", somestr)
        tmp = RE_TSPACES.sub("", tmp)
        return str(tmp)
480911
public static String removeBackslashEscape(String value) {
        StringBuffer sb = new StringBuffer();
        int i, n = value.length();
        char ch;
        boolean lastIsEscape = false;
        for (i=0; i<n; i++) {
            ch = value.charAt(i);
            if (lastIsEscape) {
                sb.append(ch);
                lastIsEscape = false;
            } else {
                if (ch=='\\') lastIsEscape = true;
                else sb.append(ch);
            }
        }
        return sb.toString();
    }
656753
function trimNull(value) {
  if (value.charCodeAt(value.length - 1) === 0) {
    return value.substring(0, value.length - 1);
  }
  return value;
}
1194475
def escape_string(self, value):
        
        if isinstance(value, EscapedString):
            return value.formatted(self._escaper)
        return self._escaper(value)
976881
function(string) {
            // If the string contains no control characters, no quote characters, and no
            // backslash characters, then we can simply slap some quotes around it.
            // Otherwise we must also replace the offending characters with safe
            // sequences.    
            var m = {
                '\b': '\\b',
                '\t': '\\t',
                '\n': '\\n',
                '\f': '\\f',
                '\r': '\\r',
                '"' : '\\"',
                '\\': '\\\\'
            };
            if(/["\\\x00-\x1f]/.test(string)) {
                return '"' + string.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                    var c = m[b];
                    if(c) {
                        return c;
                    }
                    c = b.charCodeAt();
                    return '\\u00' +
                        Math.floor(c / 16).toString(16) +
                        (c % 16).toString(16);
                }) + '"';
            }
            return '"' + string + '"';
        }
146146
def strip_spaces_and_quotes(value):
    
    value = value.strip() if value else ""
    if value and len(value) > 1 and (value[0] == value[-1] == '"'):
        value = value[1:-1]
    if not value:
        value = ""
    return value
200757
def quote_plus(string, safe='', encoding=None, errors=None):
    
    # Check if ' ' in string, where string may either be a str or bytes.  If
    # there are no spaces, the regular quote will produce the right answer.
    if ((isinstance(string, str) and ' ' not in string) or
        (isinstance(string, bytes) and b' ' not in string)):
        return quote(string, safe, encoding, errors)
    if isinstance(safe, str):
        space = str(' ')
    else:
        space = bytes(b' ')
    string = quote(string, safe + space, encoding, errors)
    return string.replace(' ', '+')
282753
public String cleanupPreFormatted(String value) {
        String result = value;
        if (value != null) {
            Matcher matcher = PRE_FORMATTED_PATTERN.matcher(value);
            if (matcher.matches()) {
                String escapedBody = matcher.group(1);
                result = StringEscapeUtils.unescapeHtml4(escapedBody);
            }
        }
        return result;
    }
658401
private static String stripSingleDoubleQuote(String input) {
    if (StringUtils.isEmpty(input)) {
      return input;
    }

    if (input.startsWith(SINGLE_QUOTE_STRING)
        || input.startsWith(DOUBLE_QUOTE_STRING)) {
      input = input.substring(1);
    }

    if (input.endsWith(SINGLE_QUOTE_STRING)
        || input.endsWith(DOUBLE_QUOTE_STRING)) {
      input = input.substring(0, input.length() - 1);
    }

    return input;
  }
1362853
function trim(str, targetStr) {
    var retStr = "";
    var regStr;

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

    if (typeof targetStr != "string" || !targetStr) {
        targetStr = "\\s";
    }

    regStr = "^" + targetStr + "*(.*?)" + targetStr + "*$";
    regStr = new RegExp(regStr);

    str = str.replace(regStr, "$1");
    return str;
}
1217987
def _escape(value):
        
        value = str(value)
        for char, escaped in {' ': '\ ', ',': '\,', '"': '\"'}.items():
            value = value.replace(char, escaped)
        return value
845362
static void unescapeBraceFormat(StringBuilder out, String message, int start, int end) {
    int pos = start;
    boolean isQuoted = false;
    while (pos < end) {
      char c = message.charAt(pos++);
      // We catch single quotes and escaped single quotes.
      if (c != '\\' && c != '\'') {
        continue;
      }
      int quoteStart = pos - 1;
      if (c == '\\') {
        // Shouldn't risk index out of bounds here because that would be a trailing single '\'.
        c = message.charAt(pos++);
        if (c != '\'') {
          continue;
        }
      }
      // Always skip the first single-quote we find.
      out.append(message, start, quoteStart);
      start = pos;
      if (pos == end) {
        break;
      }
      if (isQuoted) {
        isQuoted = false;
      } else if (message.charAt(pos) != '\'') {
        isQuoted = true;
      } else {
        // If there are two adjacent single-quotes, advance our position so we don't detect it
        // when we go back to the top of the loop (this does mean reading that same char twice
        // if it wasn't a single quote, but this is relatively rare).
        pos++;
      }
    }
    // Append the last section (if it's non empty).
    if (start < end) {
      out.append(message, start, end);
    }
  }
1350148
String trim(String string) {
        BaseFont ft = font.getFont();
        if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') {
            while (string.endsWith("\u0001")) {
                string = string.substring(0, string.length() - 1);
            }
        }
        else {
            while (string.endsWith(" ") || string.endsWith("\t")) {
                string = string.substring(0, string.length() - 1);
            }
        }
        return string;
    }
1222753
function unquote(str) {
		var ch = str.charAt(0);
		if (ch == '"' || ch == "'") {
			str = str.substr(1);
			var last = str.charAt(str.length - 1);
			if (last === ch) {
				str = str.substr(0, str.length - 1);
			}
		}

		return str;
	}
554284
def clean_value(self, value):
        '''
        
        '''
        # We have to clean before checking min/max length. It's done in
        # separate method to allow additional clean action in subclasses.
        if self.nontext_replacement is not None:
            value = replace_nontext(value, self.nontext_replacement)
        if self.strip:
            value = value.strip()
        return value