Skip to content

OACDesigns/simple-statamic-regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Simple Statamic Strip and Replace (with Regex)

A simple variable modifier for Statamic to strip out or replace certain characters using regex.

##Installation Create a folder called strip in your _add-ons folder, and copy mod.strip.php into it.

##Usage

Strip out all "Mr" and "Ms" (case insensitive)

{{ value|strip:/mr*/i|strip:/ms*/i }}

Strip out carriage returns (line breaks)

{{ value|strip:NL }}

Strip out spaces

{{ value|strip:SPACE }}

Strip out spaces and carriage returns (line breaks)

{{ value|strip:SPACE|strip:NL }}

Replace spaces with underscores

{{ value|strip:SPACE:_ }}

##NOTES Some characters won't work with Statamic's variable modifier syntax, such as using brackets () [], backward slashes \ and spaces.

This is just a basic modifier so advanced use with these disallowed characters hasn't been implemented.
However for regex groups you can just stack the modifier multiple times (see above), and for spaces and the special regex modifier for line breaks you can use SPACE and NL respectively.

About

A simple regex variable modifier for Statamic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages