Download the PHP package regex-guard/regex-guard without Composer

On this page you can find all versions of the php package regex-guard/regex-guard. 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 regex-guard

RegexGuard

Build Status Coverage Status Scrutinizer Quality Score Latest Stable Version Total Downloads License SensioLabsInsight Dependency Status Reference Status

Why?

PHP core preg_* functions do not offer any good way to validate a regular expression before usage. Some core functions return false for invalid regular expressions but they also emit uncatchable warnings.

RegexGuard is a wrapper that allows you to validate regular expressions and keep your API away from uncatchable PCRE compilation warnings.

Composer Installation

Through terminal: composer require regex-guard/regex-guard:~1.0 :8ball:

Quick Example

First grab a RegexGuard instance:

Validate your regex:

And there is more...

RegexGuard API

Internally, RegexGuard instance sandboxes all preg_* functions calls and handle errors in a convenient way. All preg_* core functions are fully represented:

::isRegexValid($pattern)

Validates a given regexp. Returns true when PCRE string is valid, false otherwise:

::validateRegexOrFail($pattern)

Validates a given regexp or throw \RegexGuard\RegexException if PCRE is invalid:

::match($pattern, $subject, &$matches=null, $flags=0, $offset=0)

Same as preg_match but throws a \RegexGuard\RegexException when an invalid PCRE string is given:

::matchAll($pattern,$subject,&$matches=null,$flags=?,$offset=0)

Same as preg_match_all but throws a \RegexGuard\RegexException when an invalid PCRE string is given:

NOTE: $flags default value depends on your PHP version.

::filter($pattern, $subject, $limit = -1, $flags = 0)

Same as preg_filter but throws a \RegexGuard\RegexException when an invalid PCRE string is given:

::grep($pattern, $input, $flags = 0)

Same as preg_grep but throws a RegexGuard\RegexException when an invalid PCRE string is given:

::replace($pattern, $replace, $subject, $limit=-1, &$count=null)

Same as preg_replace but throws a \RegexGuard\RegexException when an invalid PCRE string is given:

::split($pattern, $subject, $limit = -1, $flags = 0)

Same as preg_split but throws a \RegexGuard\RegexException when an invalid PCRE string is given:

Avoiding Exceptions

You can avoid try catch blocks by telling RegexGuard not to throw exceptions when an invalid regular expression is encountered:

This can be useful to avoid verbosity when your API needs to validate regexp arguments all over the place, but you will have to be extra careful when checking results!

Manual Instantiation

Features

Contribution Guide

  1. Fork regex-guard
  2. Clone forked repository
  3. Install composer dependencies $ composer install
  4. Run unit tests $ phpunit
  5. Modify code: correct bug, implement feature
  6. Back to step 4
  7. Pull request to master branch

Copyright

Copyright (c) 2014 Márcio Almada. Distributed under the terms of an MIT-style license. See LICENSE for details.


All versions of regex-guard 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 regex-guard/regex-guard contains the following files

Loading the files please wait ....