@Immutable
    public static String strip_tags(String string, Memory allowTags) {
        StringBuilder result = new StringBuilder();

        Set<String> allowedTagMap = null;

        if (allowTags != null) {
            allowedTagMap = getAllowedTags(allowTags.toString());
        }

        int len = string.length();
        for (int i = 0; i < len; i++) {
            char ch = string.charAt(i);

            if (i + 1 >= len || ch != '<') {
                result.append(ch);
                continue;
            }

            ch = string.charAt(i + 1);

            if (Character.isWhitespace(ch)) {
                i++;

                result.append('<');
                result.append(ch);
                continue;
            }

            int tagNameStart = i + 1;

            if (ch == '/') {
                tagNameStart++;
            }

            int j = tagNameStart;
            while (j < len
                && (ch = string.charAt(j)) != '>'
                // && ch != '/'
                && !Character.isWhitespace(ch)) {
                j++;
            }

            String tagName = string.substring(tagNameStart, j);
            int tagEnd = 0;

            if (allowedTagMap != null && allowedTagMap.contains(tagName)) {
                result.append(string, i, Math.min(j + 1, len));
            } else {
                while (j < len && (ch = string.charAt(j)) != '<') {

                    if (ch == '>') {
                        tagEnd = j;
                    }
                    j++;
                }
            }

            i = (tagEnd != 0) ? tagEnd : j;
        }

        return result.toString();
    }
Parses the cslashes bitmap returning an actual bitmap.

@param charset the bitmap string

@return the actual bitmap
exts/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/StringFunctions.java