定制 shroophp/pattern 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shroophp/pattern

Composer 安装命令:

composer require shroophp/pattern

包简介

A library for simple pattern matching.

README 文档

README

A library for simple pattern matching.

Installation

composer require 'shroophp/pattern ^1.0'

Example Usage

By default, patterns will be interpreted using a simple curly-brace syntax. Each key specified within curly-braces will equate to a lazy regular expression group (i.e. (.*?)).

<?php

use ShrooPHP\Pattern\Interpreter;

require 'vendor/autoload.php';

$interpreter = new Interpreter;
$pattern = $interpreter->interpret('Hello, {subject}!');

$world = $pattern->match('Hello, world!'); // array('subject' => 'world')
$mismatch = $pattern->match('Goodbye, galaxy!'); // null

Tokens other than curly-braces may be used by passing them to the constructor of the interpreter.

<?php

use ShrooPHP\Pattern\Interpreter;

require 'vendor/autoload.php';

$interpreter = new Interpreter('(', ')');
$curly = $interpreter->interpret('{greeting}, {subject}!');

$mismatch = $curly->match('Hello, world!'); // null
$exact = $curly->match('{greeting}, {subject}!'); // array()

$round = $interpreter->interpret('(greeting), (subject)!');
$matched = $round->match('Hello, world!'); // array(
                                           //   'greeting' => 'Hello',
                                           //    'subject' => 'world'
                                           // )

By default, tokens may be escaped using a backslash (i.e. \).

<?php

use ShrooPHP\Pattern\Interpreter;

require 'vendor/autoload.php';

$interpreter = new Interpreter;
$pattern = $interpreter->interpret('\{{key\}}');

$matched = $pattern->match('{value}'); // array('key}' => 'value}')

统计信息

  • 总下载量: 529
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固