Adds PHP preg functions as Twig filters.

Using Expressive Filter {{ entry.field|preg_filter(pattern, replacement, limit) }}

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

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.

|preg_last_error(function, pattern, replacement, limit, delimiter, count)

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

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

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

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

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

Testing preg_quote {{ entry.field|preg_last_error('quote', 'NULL', 'NULL', 'NULL', delimiter) }}

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

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

Testing preg_replace_callback_array {{ entry.field|preg_last_error('callbackarray', pattern, 'NULL', limit, 'NULL', count) }}

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

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

Match First {{ entry.field|preg_match_first(pattern) }}

Match All {{ entry.field|preg_match_all(pattern) }}

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

Replace {{ entry.field|preg_replace(pattern, replacement, limit) }}

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

Replace Callback Array {{ entry.field|preg_replace_callback_array(pattern, limit, count) }}

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

Installation Instructions

To install this plugin, copy the command above to your terminal.

Reviews

This plugin doesn't have any reviews.

Active Installs
25
Version
1.01
License
MIT
Compatibility
Craft 3
Last release
January 1, 2019