PHPackages                             chattervast/expressive - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. chattervast/expressive

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

chattervast/expressive
======================

Adds PHP PCRE preg functions as Twig filters.

00PHP

Since Oct 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/chattervast/Expressive)[ Packagist](https://packagist.org/packages/chattervast/expressive)[ RSS](/packages/chattervast-expressive/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Expressive plugin for Craft CMS 3.x
===================================

[](#expressive-plugin-for-craft-cms-3x)

Adds PHP preg functions as Twig filters.

[![Screenshot](resources/img/plugin-logo.png)](resources/img/plugin-logo.png)

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 3.0.0-beta.23 or later.

Installation
------------

[](#installation)

To install the plugin, search for Expressive in the Plugin Store or follow these instructions.

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Then tell Composer to load the plugin:

    ```
     composer require Chattervast/expressive

    ```
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Expressive.

Expressive Overview
-------------------

[](#expressive-overview)

Adds PHP preg functions as Twig filters. [preg\_filter](http://php.net/manual/en/function.preg-filter.php)

[preg\_grep](http://php.net/manual/en/function.preg-grep.php)

[preg\_last\_error](http://php.net/manual/en/function.preg-last-error.php)

[preg\_match](http://php.net/manual/en/function.preg-match.php)

preg\_match\_first

[preg\_match\_all](http://php.net/manual/en/function.preg-match-all.php)

[preg\_quote](http://php.net/manual/en/function.preg-quote.php)

[preg\_replace](http://php.net/manual/en/function.preg-replace.php)

[preg\_replace\_callback](http://php.net/manual/en/function.preg-replace-callback.php)

[preg\_replace\_callback\_array](http://php.net/manual/en/function.preg-replace-callback-array.php)

[preg\_split](http://php.net/manual/en/function.preg-split.php)

Using Expressive
----------------

[](#using-expressive)

Twig will remove backslashes so double backslash your regex patterns.

### Filter

[](#filter)

`{{ entry.field|preg_filter(pattern, replacement, limit) }}`

### Grep

[](#grep)

`{{ entry.field|preg_grep(pattern) }}`

### Last Error

[](#last-error)

This filter returns the last error given on any preg function. The preg function to test with must be specified and the appropriate parameters needed for that function to work.

#### Testing preg\_filter

[](#testing-preg_filter)

`{{ entry.field|preg_last_error('filter', pattern, replacement, limit) }}`

#### Testing preg\_grep

[](#testing-preg_grep)

`{{ entry.field|preg_last_error('grep', pattern) }}`

#### Testing preg\_match

[](#testing-preg_match)

`{{ entry.field|preg_last_error('match', pattern) }}`

#### Testing preg\_match\_first

[](#testing-preg_match_first)

`{{ entry.field|preg_last_error('matchfirst', pattern) }}`

#### Testing preg\_match\_all

[](#testing-preg_match_all)

`{{ entry.field|preg_last_error('matchall', pattern) }}`

#### Testing preg\_quote

[](#testing-preg_quote)

`{{ entry.field|preg_last_error('quote', delimiter) }}`

#### Testing preg\_replace

[](#testing-preg_replace)

`{{ entry.field|preg_last_error('replace', pattern, replacement, limit) }}`

#### Testing preg\_replace\_callback

[](#testing-preg_replace_callback)

`{{ entry.field|preg_last_error('callback', pattern, callback) }}`

#### Testing preg\_replace\_callback\_array

[](#testing-preg_replace_callback_array)

`{{ entry.field|preg_last_error('callbackarray', pattern, limit, count) }}`

#### Testing preg\_split

[](#testing-preg_split)

`{{ entry.field|preg_last_error('split', pattern) }}`

### Match

[](#match)

`{{ entry.field|preg_match(pattern) }}`

### Match First

[](#match-first)

`{{ entry.field|preg_match_first(pattern) }}`

### Match All

[](#match-all)

`{{ entry.field|preg_match_all(pattern) }}`

### Quote

[](#quote)

`{{ entry.field|preg_quote(delimiter) }}`

### Replace

[](#replace)

`{{ entry.field|preg_replace(pattern, replacement, limit) }}`Example: Replace email addresses with mailto links: `{{ entry.field|preg_replace('/(\S+@\S+\.\S+)/', '$1')|raw }}`Adding the |raw filter will render the HTML.

### Replace Callback

[](#replace-callback)

`{{ entry.field|preg_replace_callback(pattern, callback) }}`

### Replace Callback Array

[](#replace-callback-array)

`{{ entry.field|preg_replace_callback_array(pattern, limit, count) }}`

### Split

[](#split)

`{{ entry.field|preg_split(pattern) }}`

Brought to you by [Chattervast](https://github.com/chattervast)

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7124d795c74d5abc96161c7cf0d4d13613aae294823a39842846d8aed7e97ac?d=identicon)[chattervast](/maintainers/chattervast)

---

Top Contributors

[![chattervast](https://avatars.githubusercontent.com/u/72415207?v=4)](https://github.com/chattervast "chattervast (3 commits)")

### Embed Badge

![Health badge](/badges/chattervast-expressive/health.svg)

```
[![Health](https://phpackages.com/badges/chattervast-expressive/health.svg)](https://phpackages.com/packages/chattervast-expressive)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

291.8k](/packages/webkinder-sproutset)[awkwardideas/switchblade

Extended blade directives for laravel

102.1k](/packages/awkwardideas-switchblade)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
