Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rudashi committed Jun 5, 2024
1 parent 80009ac commit 8c40f04
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/usage/others.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ $pattern = Regex::build()->capture(
// /(\.[a-zA-Z])/
```

Using the `lookbehind` or `lookahead` arguments you can control whether to match a subpattern without consuming characters.

```php
use Rudashi\Regex;

$pattern = Regex::build()->capture(
callback: fn (FluentBuilder $fluent) => $fluent->exactly('.')->letter(),
lookbehind: true,
);

// /(?<=\.[a-zA-Z])/
```

### `maybe`

The `maybe` method matches a pattern within a group zero or one time.
Expand All @@ -39,6 +52,16 @@ $pattern = Regex::build()->maybe(
// /(\.[a-zA-Z])?/
```

Alternatively, you can use it to search for individual characters

```php
use Rudashi\Regex;

$pattern = Regex::build()->maybe(0);

// /(0?/
```

### `oneOf`

The `oneOf` method alternatively matches any of the given characters.
Expand Down

0 comments on commit 8c40f04

Please sign in to comment.