Parse a list of hex numbers and return a string
@param string String of hex numbers.
@param minLength Minimal length.
@param separator Separator.
@return A string from hex numbers.
544556
public static String fromHex(String string, int minLength, Pattern separator) {
        StringBuilder buffer = new StringBuilder();
        String[] parts = separator.split(string);
        for (String part : parts) {
            if (part.length() < minLength) {
                throw new IllegalArgumentException("code point too short: " + part);
            }
            int cp = Integer.parseInt(part, 16);
            buffer.appendCodePoint(cp);
        }
        return buffer.toString();
    }
362225
String parseString() throws IOException {
        buf.setLength(0);
        char next = readNext();
        while (next != '"') {
            if (next == '\\') {
                parseEscape();
            } else {
                buf.append(next);
            }
            next = readNext();
        }
        return buf.toString();
    }
1189777
public static String[] split(String str, String separator, boolean trim) {
        if (str == null) {
            return null;
        }

        char sep = separator.charAt(0);

        ArrayList<String> strList = new ArrayList<String>();
        StringBuilder split = new StringBuilder();
        int index = 0;
        while ((index = StringUtils.findNext(str, sep, StringUtils.ESCAPE_CHAR, index, split)) >= 0) {
            ++index; // move over the separator for next search
            strList.add(split.toString());
            split.setLength(0); // reset the buffer
        }

        strList.add(split.toString());
        // remove trailing empty split(s)
        if (trim) {
            int last = strList.size(); // last split
            while (--last>=0 && "".equals(strList.get(last))) {
                strList.remove(last);
            }
        }

        return strList.toArray(new String[strList.size()]);
    }
865644
public static String[] split(String str, String separator){
    
    	return Pattern.compile(separator).split(str, -1);
    }
43088
public function isValidStringLength($str, $min = null, $max = null): bool
    {
        $len = mb_strlen($str, 'UTF-8');

        return (($min !== null) && ($len >= $min)) || (($max !== null) && ($len <= $max));
    }
1099778
private String[] parseStringArray(final String list) {
		StringTokenizer tokenizer = new StringTokenizer(list, ",", false);
		int length = tokenizer.countTokens();
		String[] arr = new String[length];

		for (int i = 0; tokenizer.hasMoreElements(); i++) {
			arr[i] = cleanSpaces(tokenizer.nextToken());
		}

		return arr;
	}
265432
public static final void hexToBytes(String s, byte[] out, int off)
            throws NumberFormatException, IndexOutOfBoundsException {

        int slen = s.length();
        if ((slen % 2) != 0) {
            s = '0' + s;
        }

        if (out.length < off + slen / 2) {
            throw new IndexOutOfBoundsException(
                    "Output buffer too small for input (" + out.length + '<'
                            + off + slen / 2 + ')');
        }

        // Safe to assume the string is even length
        byte b1, b2;
        for (int i = 0; i < slen; i += 2) {
            b1 = (byte) Character.digit(s.charAt(i), 16);
            b2 = (byte) Character.digit(s.charAt(i + 1), 16);
            if ((b1 < 0) || (b2 < 0)) {
                throw new NumberFormatException();
            }
            out[off + i / 2] = (byte) (b1 << 4 | b2);
        }
    }
282663
public static String[] splitByLength(String str, int len) {
		int partCount = str.length() / len;
		int lastPartCount = str.length() % len;
		int fixPart = 0;
		if (lastPartCount != 0) {
			fixPart = 1;
		}

		final String[] strs = new String[partCount + fixPart];
		for (int i = 0; i < partCount + fixPart; i++) {
			if (i == partCount + fixPart - 1 && lastPartCount != 0) {
				strs[i] = str.substring(i * len, i * len + lastPartCount);
			} else {
				strs[i] = str.substring(i * len, i * len + len);
			}
		}
		return strs;
	}
252230
static
	public String trim(String string){
		int length = string.length();

		int trimmedLength = length;

		while(trimmedLength > 0){
			char c = string.charAt(trimmedLength - 1);

			if(!Character.isWhitespace(c)){
				break;
			}

			trimmedLength--;
		}

		if(trimmedLength < length){
			string = string.substring(0, trimmedLength);
		}

		return string;
	}
1307659
public Collection<Text> split(char separator) {
        int pointer = pos;
        int limit = pos + len;
        int mark = pointer;

        ArrayList<Text> tokens = new ArrayList<Text>();
        while (pointer < limit) {
            if (chars[pointer] == separator) {
                tokens.add(new Text(chars, mark, pointer - mark));
                mark = pointer + 1;
            }
            pointer++;
        }
        
        tokens.add(new Text(chars, mark, limit - mark));        
        return tokens;
    }
1128254
public static Binary fromHexString(String hex) {
        if (hex.length() % 2 != 0) {
            throw new IllegalArgumentException("Illegal hex string length: " + hex.length());
        }
        final int len = hex.length() / 2;
        final byte[] out = new byte[len];
        for (int i = 0; i < len; ++i) {
            int pos = i * 2;
            String part = hex.substring(pos, pos + 2);
            out[i] = (byte) Integer.parseInt(part, 16);
        }
        return Binary.wrap(out);
    }
92435
static final byte[] fromHex(final String hex) throws ParseException {
		final int len = hex.length();
		final byte[] out = new byte[len / 2];
		for (int i = 0, j = 0; i < len; i++) {
			char c = hex.charAt(i);
			int v = 0;
			if ((c >= '0') && (c <= '9')) {
				v = (c - '0');
			} else if ((c >= 'A') && (c <= 'F')) {
				v = (c - 'A') + 0xA;
			} else if ((c >= 'a') && (c <= 'f')) {
				v = (c - 'a') + 0xA;
			} else {
				throw new ParseException("Invalid char", j);
			}
			if ((i & 1) == 0) {
				out[j] |= (v << 4);
			} else {
				out[j++] |= v;
			}
		}
		return out;
	}
1128503
public static <E> String listAsString(List<E> list, String separator) {

        StringBuffer string = new StringBuffer(128);
        Iterator<E> it = list.iterator();
        while (it.hasNext()) {
            string.append(it.next());
            if (it.hasNext()) {
                string.append(separator);
            }
        }
        return string.toString();
    }
1082459
public static List<String> split(String string, String delimiter) {
        return split(string, delimiter, true);
    }
188686
static protected function parseInteger($value, $offset, $minLength, $maxLength)
    {
        for ($len = $maxLength; $len >= $minLength; --$len) {
            $v = self::$_mbstringAvailable ? mb_substr($value, $offset, $len, APP_CHARSET) : substr($value, $offset, $len);
            if (ctype_digit($v) && (self::$_mbstringAvailable ? mb_strlen($v, APP_CHARSET) : strlen($v)) >= $minLength) {
                return $v;
            }
        }
        return false;
    }
988973
public static function minLength($value, int $minLength, string $encoding = 'UTF-8'): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        $strlen = (int) mb_strlen((string) $value, $encoding);

        return $strlen >= $minLength;
    }
657637
function(string, maxLength) {
            if (!string) return string;
            if (maxLength < 1) return string;
            if (string.length <= maxLength) return string;
            if (maxLength == 1) return string.substring(0,1) + '...';

            var midpoint = Math.ceil(string.length / 2);
            var toremove = string.length - maxLength;
            var lstrip = Math.ceil(toremove/2);
            var rstrip = toremove - lstrip;
            return string.substring(0, midpoint-lstrip) + '...' + string.substring(midpoint+rstrip);
        }