Download the PHP package git-mz/tagmatch without Composer

On this page you can find all versions of the php package git-mz/tagmatch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tagmatch

tagmatch

PHP 文本关键词匹配与标签替换库。

v2 匹配规则

v2 重写了核心匹配算法,采用 Unicode Trie + 左边优先 + 最长匹配:

  1. 从文本左侧开始逐字符扫描。
  2. 同一个位置存在多个关键词时,优先选择最长关键词。
  3. 一个关键词匹配成功后,直接跳过已经消费的字符,因此不会产生重叠匹配。
  4. 不再通过修改原始文本或插入占位符来阻止重复匹配。
  5. 默认会替换关键词的所有非重叠出现位置。

例如关键词同时存在:

文本:

匹配结果只有:

而不是拆成「北京」+「大学」。

使用方法

引入

匹配

限制匹配数量

wordNum = 0 表示返回全部匹配结果。

替换

默认替换所有非重叠匹配。

如果只希望每个关键词替换第一次:

自定义 HTML 属性

为了兼容旧版本 API,第二个参数仍然接受 HTML 属性字符串:

算法说明

关键词会预先构建成 Unicode Trie。匹配时从文本当前位置沿 Trie 向下查找,并记录最后一个完整关键词节点,因此天然支持最长匹配。

相比旧版本逐个关键词调用 strpos(),新版本不会在每个文本位置重新遍历全部关键词;实际匹配成本主要取决于文本长度和当前位置可能形成的关键词前缀长度。

测试

测试覆盖:

兼容性

setTree()、getTagWord()、replace() 保留,方便现有代码迁移到新版。


All versions of tagmatch with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package git-mz/tagmatch contains the following files

Loading the files please wait ...