从树种摘除一个文本
@param $index_str
972916
public function delete($index_str, $deltree = false, $is_py = false, $chinese = "") {
        $str = trim($index_str);
        $chinese = trim($chinese);
        if ($is_py && empty($chinese)) {
            return false;
        }

        $delstr_arr = $this->convertStrToH($str);
        $len = count($delstr_arr);
        //提取树
        $childTree = &$this->nodeTree;
        $del_index = array();
        //提取树中的相关索引
        for ($i = 0; $i < $len; $i++) {
            $code = $delstr_arr[$i];
            //命中将其纳入索引范围
            if (isset($childTree[$code])) {
                //del tree
                $del_index[$i] = [
                    'code' => $code,
                    'index' => &$childTree[$code]
                ];
                //若检索到最后一个字，检查是否是一个关键词的末梢
                if ($i == ($len - 1) && !$childTree[$code]['end']) {
                    return false;
                }
                $childTree = &$childTree[$code]['child'];
            } else {
                //发现没有命中 删除失败
                return false;
            }
        }
        $idx = $len - 1;
        //删除整棵树
        if ($deltree) {
            //清空子集
            $del_index[$idx]['index']['child'] = array();
        }
        //只有一个字 直接删除
        if ($idx == 0) {
            //如果是拼音 只删除相应的拼音索引
            if ($is_py) {
                //清除单个拼音索引
                if (isset($this->nodeTree[$del_index[$idx]['code']]['chinese_list'])) {
                    $is_del = false;
                    foreach ($this->nodeTree[$del_index[$idx]['code']]['chinese_list'] as $key=>$node) {
                        if ($node['word'] == $chinese){
                            unset($this->nodeTree[$del_index[$idx]['code']]['chinese_list'][$key]);
                            $is_del = true;
                            break;
                        }
                    }
                    if($is_del && 0 != count($this->nodeTree[$del_index[$idx]['code']]['chinese_list'])){
                         return true;
                    }
                    if(!$is_del){
                        return false;
                    }
                    //如果依然存在中文数据 则继续向下跑删除节点
                }
            }else{
                if (count($del_index[$idx]['index']['child']) == 0) {
                    unset($this->nodeTree[$del_index[$idx]['code']]);
                    return true;
                }
            }

        }
        //末梢为关键词结尾，且存在子集 清除结尾标签
        if (count($del_index[$idx]['index']['child']) > 0) {
            $del_index[$idx]['index']['end'] = false;
            $del_index[$idx]['index']['data'] = array();
            unset($del_index[$idx]['index']['full']);
            return true;
        }
//        var_dump($this->nodeTree['e59bbd']);exit();
        //以下为末梢不存在子集的情况
        //倒序检索 子集大于2的 清除child
        for (; $idx >= 0; $idx--) {
            //检测子集 若发现联字情况 检测是否为其他关键词结尾
            if (count($del_index[$idx]['index']['child']) > 0) {
                //遇到结束标记或者count>1的未结束节点直接清空子集跳出
                if ($del_index[$idx]['index']['end'] == true || $del_index[$idx]['index']['child'] > 1) {
                    //清空子集
                    $child_code = $del_index[$idx + 1]['code'];
                    unset($del_index[$idx]['index']['child'][$child_code]);
                    return true;
                }

            }
        }
        return false;
    }
1258405
public void addString(String str) {
        if (mSize == mStrings.length) {
            String[] old = mStrings;
            int oldSize = old.length;
            mStrings = new String[oldSize + (oldSize << 1)];
            System.arraycopy(old, 0, mStrings, 0, oldSize);
        }
        mStrings[mSize++] = str;
    }
514119
public function init( $keyword_file )
    {
        // キーワードファイルの読み込み
        $keywords = array();
        $fp = fopen( $keyword_file, 'r' );
        if ( !$fp ) {
            throw new PhpSourceParserException( self::ERROR_FILENOTFOUND, "Keyword file not found:$keyword_file" );
        }
        while ( !feof($fp) ) {
            $buffer = fgets( $fp, 4096 );
            $keyword = trim($buffer);
            $keywords[$keyword] = 1;
        }
        fclose( $fp );
        $this->_keywords = $keywords;
    }
1112698
function _getSubstring (str, index) {
  if (!isIndex(index)) {
    // TODO: better error message
    throw new TypeError('Index expected')
  }
  if (index.size().length !== 1) {
    throw new DimensionError(index.size().length, 1)
  }

  // validate whether the range is out of range
  const strLen = str.length
  validateIndex(index.min()[0], strLen)
  validateIndex(index.max()[0], strLen)

  const range = index.dimension(0)

  let substr = ''
  range.forEach(function (v) {
    substr += str.charAt(v)
  })

  return substr
}
1233036
public function serializeIndex()
    {
        foreach (self::$indexFields as $f)
        {
            $index[$f] = $this->{$f};
        }

        $res = json_encode($index, JSON_UNESCAPED_UNICODE);

        return $res;
    }
305565
public function addStringList($str_name, $bol_index = TRUE)
    {
        return $this->addProperty($str_name, self::PROPERTY_STRING_LIST, $bol_index);
    }
443600
function (str, index) {
            var res = false;
            for (var i = index - 1; i >= 0; i--) {
                if (str.charAt(i) == "\\") {
                    res = !res;
                } else {
                    return res;
                }
            }
            return res;
        }
656865
public function readFile(string $file_name)
    {
        $contents = @file_get_contents($file_name);
        if ($contents === false)
            throw new IOException("Failed to read file contents");

        $contents = Encoding::removeBOM($contents);
        return $this->readString(file_get_contents($file_name));
    }
979367
public function extractByIndex($p_index)
    {
        $v_result=1;

        // ----- Reset the error handler
        $this->privErrorReset();

        // ----- Check archive
        if (!$this->privCheckFormat()) {
            return(0);
        }

        // ----- Set default values
        $v_options = array();
    //        $v_path = "./";
        $v_path = '';
        $v_remove_path = "";
        $v_remove_all_path = false;

        // ----- Look for variable options arguments
        $v_size = func_num_args();

        // ----- Default values for option
        $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;

        // ----- Look for arguments
        if ($v_size > 1) {
            // ----- Get the arguments
            $v_arg_list = func_get_args();

            // ----- Remove form the options list the first argument
            array_shift($v_arg_list);
            $v_size--;

            // ----- Look for first arg
            if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
                // ----- Parse the options
                $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
                    PCLZIP_OPT_PATH => 'optional',
                    PCLZIP_OPT_REMOVE_PATH => 'optional',
                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
                    PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
                    PCLZIP_OPT_ADD_PATH => 'optional',
                    PCLZIP_CB_PRE_EXTRACT => 'optional',
                    PCLZIP_CB_POST_EXTRACT => 'optional',
                    PCLZIP_OPT_SET_CHMOD => 'optional',
                    PCLZIP_OPT_REPLACE_NEWER => 'optional',
                    PCLZIP_OPT_STOP_ON_ERROR => 'optional',
                    PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
                    PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
                    PCLZIP_OPT_TEMP_FILE_ON => 'optional',
                    PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
                ));
                if ($v_result != 1) {
                    return 0;
                }

                // ----- Set the arguments
                if (isset($v_options[PCLZIP_OPT_PATH])) {
                    $v_path = $v_options[PCLZIP_OPT_PATH];
                }
                if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
                    $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
                }
                if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
                    $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
                }
                if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
                    // ----- Check for '/' in last path char
                    if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
                        $v_path .= '/';
                    }
                    $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
                }
                if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
                    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;
                } else {
                }
            } else {
                // ----- Look for 2 args
                // Here we need to support the first historic synopsis of the
                // method.

                // ----- Get the first argument
                $v_path = $v_arg_list[0];

                // ----- Look for the optional second argument
                if ($v_size == 2) {
                    $v_remove_path = $v_arg_list[1];
                } elseif ($v_size > 2) {
                    // ----- Error log
                    PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

                    // ----- Return
                    return 0;
                }
            }
        }

        // ----- Trace

        // ----- Trick
        // Here I want to reuse extractByRule(), so I need to parse the $p_index
        // with privParseOptions()
        $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
        $v_options_trick = array();
        $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, array (PCLZIP_OPT_BY_INDEX => 'optional'));
        if ($v_result != 1) {
            return 0;
        }
        $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];

        // ----- Look for default option values
        $this->privOptionDefaultThreshold($v_options);

        // ----- Call the extracting fct
        if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
            return(0);
        }

        // ----- Return
        return $p_list;
    }
1290923
private function string(string $str): void
    {
        $this->sql = $str;
        $this->prepare = $str;
        $this->param = [];
    }
1123257
public static function create_index($table, $index_columns, $index_name = '', $index = '', $db = null)
	{
		static $accepted_index = array('UNIQUE', 'FULLTEXT', 'SPATIAL', 'NONCLUSTERED', 'PRIMARY');

		// make sure the index type is uppercase
		$index !== '' and $index = strtoupper($index);

		if (empty($index_name))
		{
			if (is_array($index_columns))
			{
				foreach ($index_columns as $key => $value)
				{
					if (is_numeric($key))
					{
						$index_name .= ($index_name == '' ? '' : '_').$value;
					}
					else
					{
						$index_name .= ($index_name == '' ? '' : '_').str_replace(array('(', ')', ' '), '', $key);
					}
				}
			}
			else
			{
				$index_name = $index_columns;
			}
		}

		if ($index == 'PRIMARY')
		{
			$sql = 'ALTER TABLE ';
			$sql .= \DB::quote_identifier(\DB::table_prefix($table, $db ? $db : static::$connection), $db ? $db : static::$connection);
			$sql .= ' ADD PRIMARY KEY ';
			if (is_array($index_columns))
			{
				$columns = '';
				foreach ($index_columns as $key => $value)
				{
					if (is_numeric($key))
					{
						$columns .= ($columns=='' ? '' : ', ').\DB::quote_identifier($value, $db ? $db : static::$connection);
					}
					else
					{
						$columns .= ($columns=='' ? '' : ', ').\DB::quote_identifier($key, $db ? $db : static::$connection).' '.strtoupper($value);
					}
				}
				$sql .= ' ('.$columns.')';
			}
		}
		else
		{
			$sql = 'CREATE ';

			$index !== '' and $sql .= (in_array($index, $accepted_index)) ? $index.' ' : '';

			$sql .= 'INDEX ';
			$sql .= \DB::quote_identifier($index_name, $db ? $db : static::$connection);
			$sql .= ' ON ';
			$sql .= \DB::quote_identifier(\DB::table_prefix($table, $db ? $db : static::$connection), $db ? $db : static::$connection);
			if (is_array($index_columns))
			{
				$columns = '';
				foreach ($index_columns as $key => $value)
				{
					if (is_numeric($key))
					{
						$columns .= ($columns=='' ? '' : ', ').\DB::quote_identifier($value, $db ? $db : static::$connection);
					}
					else
					{
						$columns .= ($columns=='' ? '' : ', ').\DB::quote_identifier($key, $db ? $db : static::$connection).' '.strtoupper($value);
					}
				}
				$sql .= ' ('.$columns.')';
			}
			else
			{
				$sql .= ' ('.\DB::quote_identifier($index_columns, $db ? $db : static::$connection).')';
			}
		}


		return \DB::query($sql, \DB::UPDATE)->execute($db ? $db : static::$connection);
	}
953913
public static function str_split(&$str, int $split_length=1) {
		if ($split_length < 1) {
			$str = false;
			return false;
		}

		cast::string($str, true);

		$str_length = v_mb::strlen($str);
		$out = array();

		for ($i = 0; $i < $str_length; $i += $split_length) {
			$out[] = v_mb::substr($str, $i, $split_length);
		}

		$str = $out;
		return true;
	}
334733
function (str) {
      var index = this.html.indexOf(str, this.currentChar) + str.length;
      if (index === -1)
        this.currentChar = this.html.length;
      this.currentChar = index;
    }
441174
public static function validIndex( $index, $value )
    {
        if ( is_array( $value ) )
        {
            return ( count( $value ) > $index && $index >= 0 );
        }
        elseif ( is_string( $value ) )
        {
            return ( strlen( $value ) > $index && $index >= 0 );
        }

        return FALSE;
    }
894757
public static function str_pad($str, int $pad_length, $pad_string=' ', int $pad_type=\STR_PAD_RIGHT) {
		ref\mb::str_pad($str, $pad_length, $pad_string, $pad_type);
		return $str;
	}
213756
public function __column(string $column, string $index_key = null):array{
		return array_column($this->__toArray(), $column, $index_key);
	}
1250926
function(str) {
            var root, error = null;

            i = j = current = 0;
            chunks = [];
            input = str.replace(/\r\n/g, '\n');
            if (env.filename) {
                that.env.inputs[env.filename] = input;
            }

            // Split the input into chunks.
            chunks = (function (chunks) {
                var j = 0,
                    skip = /(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g,
                    comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
                    string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g,
                    level = 0,
                    match,
                    chunk = chunks[0],
                    inParam;

                for (var i = 0, c, cc; i < input.length;) {
                    skip.lastIndex = i;
                    match = skip.exec(input);
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                        }
                    }
                    c = input.charAt(i);
                    comment.lastIndex = string.lastIndex = i;

                    match = string.exec(input)
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                            continue;
                        }
                    }

                    if (!inParam && c === '/') {
                        cc = input.charAt(i + 1);
                        if (cc === '/' || cc === '*') {
                            match = comment.exec(input);
                            if (match) {
                                if (match.index === i) {
                                    i += match[0].length;
                                    chunk.push(match[0]);
                                    continue;
                                }
                            }
                        }
                    }

                    switch (c) {
                        case '{':
                            if (!inParam) {
                                level ++;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case '}':
                            if (!inParam) {
                                level --;
                                chunk.push(c);
                                chunks[++j] = chunk = [];
                            }
                            else {
                                inParam = false;
                                chunk.push(c);
                            }
                            break;
                        case '(':
                            if (!inParam) {
                                inParam = true;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case ')':
                            if (inParam) {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        default:
                            chunk.push(c);
                    }

                    i++;
                }
                if (level !== 0) {
                    error = {
                        index: i - 1,
                        message: (level > 0) ? "missing closing `}`" : "missing opening `{`",
                        filename: env.filename
                    };
                }

                return chunks.map(function (c) { return c.join(''); });
            })([[]]);

            if (error) {
                util.error(env, error);
                throw new Error('N/A');
            }

            // Start with the primary rule.
            // The whole syntax tree is held under a Ruleset node,
            // with the `root` property set to true, so no `{}` are
            // output.
            root = new tree.Ruleset([], $(this.parsers.primary));
            root.root = true;

            // Get an array of Ruleset objects, flattened
            // and sorted according to specificitySort
            root.toList = (function() {
                return function(env) {
                    env.frames = env.frames || [];


                    // call populates Invalid-caused errors
                    var definitions = this.flatten([], [], env);
                    definitions.sort(specificitySort);
                    return definitions;
                };
            })();

            // Sort rules by specificity: this function expects selectors to be
            // split already.
            //
            // Written to be used as a .sort(Function);
            // argument.
            //
            // [1, 0, 0, 467] > [0, 0, 1, 520]
            var specificitySort = function(a, b) {
                var as = a.specificity;
                var bs = b.specificity;

                if (as[0] != bs[0]) return bs[0] - as[0];
                if (as[1] != bs[1]) return bs[1] - as[1];
                if (as[2] != bs[2]) return bs[2] - as[2];
                return bs[3] - as[3];
            };

            return root;
        }