承接 ashleydawson/globtoregex 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ashleydawson/globtoregex

Composer 安装命令:

composer require ashleydawson/globtoregex

包简介

Function that converts a glob pattern into a regular expression, extracted from the Symfony Finder component

README 文档

README

Build Status

PHP function that converts a glob pattern into a regular expression, extracted from the Symfony Finder component.

Installation

To install via Composer, do the following:

$ composer req ashleydawson/globtoregex

Requirements are:

  • PHP >= 7.1

Basic Usage

Basic usage of the function is as follows:

<?php

require __DIR__.'/vendor/autoload.php';

$regex = \AshleyDawson\GlobToRegex\glob_to_regex('/**/*.txt');

echo $regex;

Where output is:

#^(?=[^\.])/(?:(?=[^\.])[^/]++/)*(?=[^\.])[^/]*\.txt$#

Usage

The following simple example returns a set of matched file paths:

<?php

require __DIR__.'/vendor/autoload.php';

use function AshleyDawson\GlobToRegex\glob_to_regex;

$paths = [
    '/foo/bar/sample.txt', 
    '/baz/biz/example.txt', 
    '/fiz/boo/music.mp3',
];

// Find matches for the glob pattern `/**/*.txt`
$regex = glob_to_regex('/**/*.txt');

$matches = array_filter($paths, function ($path) use ($regex) {
    return preg_match($regex, $path);
});

print_r($matches);

Where output is:

Array
(
    [0] => /foo/bar/sample.txt
    [1] => /baz/biz/example.txt
)

Testing

To run the test suite, do the following:

$ vendor/bin/phpunit -c .

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固