Java Utililty Methods String Unescape

List of utility methods to do String Unescape

Description

The list of methods to do String Unescape are organized into topic(s).

Method

Stringunescape(String text)
Unescapes the String text according to the format described above in escape(String text)
if (text == null)
    return null;
StringBuilder unescapedText = new StringBuilder(text.length());
for (int i = 0, n = text.length(); i < n;) {
    char ch = text.charAt(i);
    char nextch;
    if (i == n - 1) {
        nextch = 0;
...
Stringunescape(String text)
unescape
if (text == null)
    return null;
StringBuilder builder = new StringBuilder(text.length());
for (int i = 0; i < text.length(); i++) {
    char c = text.charAt(i);
    if (c != '\\')
        builder.append(c);
    else if (i < text.length() - 1) {
...
Stringunescape(String theValue)
Unescapes a string according to the rules for parameter escaping specified in the FHIR Specification Escaping Section
if (theValue == null) {
    return theValue;
if (theValue.indexOf('\\') == -1) {
    return theValue;
StringBuilder b = new StringBuilder();
for (int i = 0; i < theValue.length(); i++) {
...
Stringunescape(String val)
unescape
val = val.replaceAll(MARKER, "@");
int escape = val.indexOf(ESCAPE_CHAR);
while (escape >= 0 && escape < val.length() - 1) {
    char c = val.charAt(escape + 1);
    if (c == '{' || c == '}' || c == ESCAPE_CHAR) {
        val = val.substring(0, escape) + val.substring(escape + 1);
    escape = val.indexOf(ESCAPE_CHAR, escape + 1);
...
Stringunescape(String val, char quote)
Unescape escaped chars in a string 'val'.
StringBuffer buff = new StringBuffer();
for (int i = 0; i < val.length(); i++) {
    char ch = val.charAt(i);
    if (ch == '\\' && i + 1 < val.length()) {
        ch = val.charAt(++i);
        if (Character.digit(ch, 8) >= 0 && i + 2 < val.length()) {
            String code = val.substring(i, i + 3);
            i += 2;
...
Stringunescape(String value)
unescape
if (value.length() < 2) {
    return value;
if ((value.charAt(0) == '@') && (value.charAt(1) == '@')) {
    return value.substring(1);
return value;
Stringunescape(String value)
unescape
String ret = replace("&amp;", "&", value);
ret = replace("&lt;", "<", ret);
ret = replace("&gt;", ">", ret);
return ret;
StringunEscape(String value)
Unescapes the string by replacing some XML entities into plain symbols.
value = value.replaceAll("&lt;", "<");
value = value.replaceAll("&gt;", ">");
value = value.replaceAll("&amp;", "&");
value = value.replaceAll("&quot;", "\"");
value = value.replaceAll("&apos;", "'");
return value;
Stringunescape(String value)
Unescapes characters that are escaped in a call to compose.
int bsidx = value.indexOf('\\');
if (bsidx == -1) {
    return value;
StringBuilder buf = new StringBuilder();
int vlength = value.length();
for (int ii = 0; ii < vlength; ii++) {
    char ch = value.charAt(ii);
...
Stringunescape(String value)
unescape
StringBuilder valueBuilder = new StringBuilder();
for (int i = 0; i < value.length(); i++) {
    char ch = value.charAt(i);
    if (ch != '\\') {
        valueBuilder.append(ch);
    } else {
        ch = value.charAt(i + 1);
        valueBuilder.append(ch);
...