niklongstone/regex-reverse
Composer 安装命令:
composer require niklongstone/regex-reverse
包简介
Regular Expression reverter, generates a string from a provided regular expression
README 文档
README
Regular expression reverter, generates a string from the given regular expression.
Install
Via Composer
$ composer require niklongstone/regex-reverse:'^0.4.0'
Usage
<?php require ('vendor/autoload.php'); use RegRev\RegRev; echo RegRev::generate('\d'); //ouput a random number
For a list of useful regular expression, please visit: Awesome PCRE
Supported expressions
Character classes
| Expression | Description | Result |
|---|---|---|
| \d | digit | a number |
| \D | non digit | an alpha char |
| \w | word | a alphanumeric char |
| \W | non word | a non alphanumeric char |
| \s | space | a blank space |
| \S | non space | a non blank space |
Conditional and subgroup
| Expression | Description | Example | Result |
|---|---|---|---|
| () | subgroup | (\d\w)+@ | 97a987Ss@ |
| (a | b) | alternation | (a |
| * | zero or more | \d* | 123502 |
| + | one or more | \d+ | 32133 |
| ? | zero or one | \d? | 3 |
| {n} {n,} {n,m} | from n to m times | \w{1,3} | np |
Ranges
| Expression | Description | Result |
|---|---|---|
| [0-9] | range 0 to 9 | 7 |
| [a-d] | range a to b | b |
| [0-9c-f] | range 0-9 or c-f | d |
| [ab5.] | chars in list | b |
| [^ab5\.] | chars not in list | 8 |
Examples
| Expression | Result | Description |
|---|---|---|
2\d{2}-\d{3}-\d{4} |
212-686-1234 | US phone number |
\(\d{3}\)\s\d{7} |
(957) 7583632 | phone with area code |
\w+@\w+\.\D{2,3} |
yiuh@qwerty.com |
|
www\.\w+\.com |
www.h3MEb7k.com |
URL |
192\.\d{3}.255.\d{1,3} |
192.134.255.4 | Ip address |
\D{3,7}\s\D{2}\s\d{2,5} |
mslchvi Rr 861 | US address |
<TAG\s.*>.*?<\/TAG> |
<TAG fNol>ZPXApG</TAG> |
TAG |
004[0-9] \d{7,10} |
0044 75132145 | europe phone |
SE[1-9]{1}\d{1}\s[A-Z]{2}\d{2} |
SE27 GU35 | london SE post code |
SE[1-9]{1}\d{1}\s[A-Z]{2}\d{2} |
SE27 GU35 | london SE post code |
organi[sz]e |
organise or organize | US or UK spelling |
Other features
- debug:
RegRev::debug()will return an array of messages
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
niklongstone/regex-reverse 适用场景与选型建议
niklongstone/regex-reverse 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 160.62k 次下载、GitHub Stars 达 103, 最近一次更新时间为 2015 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「data」 「test」 「generation」 「regex」 「PCRE」 「regular expression」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 niklongstone/regex-reverse 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 niklongstone/regex-reverse 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 niklongstone/regex-reverse 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Toolset for generating PHP code
Testing Suite For Lumen like Laravel does.
Fabricates patterns.
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
统计信息
- 总下载量: 160.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 105
- 点击次数: 28
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-10