Skip to content

Commit

Permalink
with logo
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Jan 7, 2024
1 parent 57d6771 commit b2fb1ac
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .github/banner/regex-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/banner/regex-social.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 89 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,100 @@
[![CodeFactor](https://www.codefactor.io/repository/github/chevere/regex/badge)](https://www.codefactor.io/repository/github/chevere/regex)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/6df2d28288ad49c9afb7b5af1e0ec2ae)](https://app.codacy.com/gh/chevere/regex/dashboard)

![Regex](.github/banner/regex-logo.svg)

## Summary

Regex enables to create and handle a validated [regular expression](https://en.wikipedia.org/wiki/Regular_expression).

## Quick start

Install with [Composer](https://packagist.org/packages/chevere/regex).

```sh
composer require chevere/regex
```

## Creating Regex

Create a Regex by passing the regular expression pattern.

```php
use Chevere\Regex\Regex;

$regex = new Regex('/^Hello World!$/');
```

## Reading pattern

### As-is

The `__toString` method is used to access the pattern passed on instance creation.

```php
$string = $regex->__toString();
// /^Hello World!$/
```

### Without delimiters

The `noDelimiters` method is used to access to the regex pattern without delimiters.

```php
$string = $regex->noDelimiters();
// ^Hello World!$
```

### Without delimiters and anchors

The `noDelimitersNoAnchors` method is used to access to the regex pattern without delimiters and anchors.

```php
$string = $regex->noDelimitersNoAnchors();
// Hello World!
```

## Match

The `match` method provides [preg_match](https://www.php.net/preg-match).

```php
$array = $regex->match('Hello World!');
// [Hello World!]
```

## Match All

The `matchAll` method provides [preg_match_all](https://www.php.net/preg-match-all).

```php
$regex->matchAll();
// [Hello World!]
```

## Assert Match

The `assertMatch` method asserts that the string matches. It throws `Exceptions\NoMatchException` when failing to assert.

```php
$regex->assertMatch('Hello World!');
```

## Assert Match All

The `assertMatchAll` method asserts that the string matches all. It throws `Exceptions\NoMatchException` when failing to assert.

```php
$regex->assertMatchAll('Hello World!');
```

## Documentation

Documentation is available at [chevere.org](https://chevere.org/).
Documentation is available at [chevere.org](https://chevere.org/packages/regex).

## License

Copyright 2023 [Rodolfo Berrios A.](https://rodolfoberrios.com/)
Copyright 2024 [Rodolfo Berrios A.](https://rodolfoberrios.com/)

Chevere is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text.

Expand Down

0 comments on commit b2fb1ac

Please sign in to comment.