Download the PHP package wangqs/cut_elegant_string without Composer
On this page you can find all versions of the php package wangqs/cut_elegant_string. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package cut_elegant_string
项目说明
优雅的将中文(中英混合)字符串裁剪为长度范围内的句子,主要用于大段文字分页、分局等场景。
主要解决2痛点:
- 中英文混合字符串常规的裁剪无非是按字数(长度)裁剪,或者按段落、标点等特征值裁剪.无法【优雅】的裁剪出合适字数(长度)的整句句子。
- 中英文混合的字符串,由于编码方式原因,常规裁剪方法,无法【优雅】的中文按单个汉字,英文按单词进行统计长度和裁剪.
优雅的处理结果:
- 按规定的长度,进行整句字符串裁剪,默认会根据中文标点进行整句判断,尽量不断句、不裁剪英文单词。
- 带有分段(换行)的字符串,可以自行决定保留原分段,还是无视分段,重新合并裁剪。
- 整句判断标识(默认中文标点符号)、段落处理、采集长度等均可自定义。
Warning
:warning: 请使用 utf-8编码。
:warning: 本项目抽离于本人的其他生产项目,本着方便易用的原则,实际使用了各类字符串函数和方法达到分割效果,虽考虑了效率的处理,但仅建议使用在小文本的截剪处理上,理论上万字以内的效率和内存开销均在可控范围内。不建议直接处理万字以上的大段文本,请结合实际情况自行考量使用效率和内存开销。
:warning: 仅能处理字符串,不能直接处理包含html标签的字符串,为保证结果,会直接清理掉 html标签!
Installing
Usage
Demo
常规用法:
静态方法:
各参数可通过链式调用自定义:
License
MIT
All versions of cut_elegant_string with dependencies
PHP Build Version
Package Version
Requires
php Version
>=5.6
The package wangqs/cut_elegant_string contains the following files
Loading the files please wait ....