Download the PHP package hoels/regex without Composer

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

RegEx Wrapper

This is a wrapper around regular expressions.

Regular expressions in PHP are a common point of failure and working with match groups in particular can be a major headache. Inspired by the functionality Kotlin offers with its Regex class, I decided to start implementing a similar functionality for PHP. Hoping that one day, the PHP team will improve the preg_* functions, this library provides a very simple wrapper around regular expressions in PHP.

In contrast to the Kotlin implementation, the delimiters (e.g. / at the beginning and end of the expression) have to be set. This allows for greater flexibility.

Installation

Requirements

Composer

Documentation

Regex class

The main class of this library is the Regex class. The class currently provides the following functions:

containsMatchIn

Indicates whether there is at least one match in $input for the regex given in $regex.

find

Returns the first match in $input for the regex given in $regex. Returns null if there is no match and an MatchResult object if there is a match.

findAll

Returns an array of MatchResult objects for all matches in $input for the regex given in $regex. Returns an empty array if there is no match.

matchAt

Returns the first match in $input for the regex given in $regex, only if the match starts at $index. Returns null if there is no match and an MatchResult object if there is a match at $index.

replace

Replaces all occurrences of $regex in $input by the replacement expression $replacement. Example:

replaceFirst

Replaces the first occurrence of $regex in $input by the replacement expression $replacement. Example:

MatchResult class

The MatchResult class has three properties:

Groups

The groups property contains an array of MatchGroup objects.

The first element (index 0) will always represent the matched string, therefore the value and offset properties of the MatchGroup object will be the same as the ones of its MatchResult parent.

If the regular expression did not declare any groups, the first element will be the only one in the array.

If the regular expression does declare groups, there will be a MatchGroup object for every group in the order of appearance. Therefore, the first group will have the index 1, the second the index 2, and so on. If there are named groups, there will be additional array elements with the name as index. Note that the MatchGroup object will have the same properties as the one with the numeric index, but the object reference will not be the same.

MatchGroup class

The MatchGroup class has two properties:

Usage

Regex::containsMatchIn

Regex::find


All versions of regex with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
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 hoels/regex contains the following files

Loading the files please wait ....