Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 9, 2024 via composer

composer/pcre 3.1.0

PCRE wrapping library that offers type-safe preg_* replacements.
Package summary
Share
0
issues
1
license
1
MIT
Package created
30 Nov 2021
Version published
17 Nov 2022
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
composer/pcre@3.1.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of composer/pcre 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does composer/pcre do?

The Composer PCRE library is a PHP package that provides a type-safe wrapper for preg_* functions. This means that it ensures these functions do not fail silently, avoiding unexpected nulls that may not be handled correctly. It simplifies the possible return values from all the preg_* functions, which are usually filled with various edge cases. This makes the library particularly useful when working with static analysis tools like PHPStan or Psalm. This library is ideal if you're working with regular expressions in PHP and looking for a way to handle exceptions and unexpected return values more gracefully.

How do you use composer/pcre?

To utilize the Composer PCRE library, you need to include it in your project using Composer. In your terminal, execute the command:

$ composer require composer/pcre

Once the package is installed, you can use its various functionalities in your PHP script. For example, instead of using preg_match() or preg_match_all(), you can use Preg::match() or Preg::matchAll() respectively from the Preg class provided by the library.

Here is how to use these methods:

use Composer\Pcre\Preg;

if (Preg::match('{fo+}', $string, $matches)) { /*...*/ }
if (Preg::matchWithOffsets('{fo+}', $string, $matches)) { /*...*/ }
$newString = Preg::replace('{fo+}', 'bar', $string);

The library also provides match methods that return bool rather than int, for stricter type safety. And if you need stricter type safety for match groups, the library provides *StrictGroups method variants.

Where are the composer/pcre docs?

The documentation for the Composer PCRE library is embedded within its GitHub repository. Detailed explanations of the library's functionalities, including its methods, return types, installation process, requirements, and usage examples can be found on its GitHub page at https://github.com/composer/pcre.git. Particular attention should be paid to the 'Basic Usage' and 'Restrictions / Limitations' sections for comprehensive guidance on how to effectively utilize the library. Also, the GitHub repository contains the source code for the project, which may prove useful for those who wish to gain deeper insights into the workings of the library.