Skip to content Skip to footer navigation
🏰 Statamic Summit 2027 Feb 16–19 Talks, workshops, and three nights in a German castle. Get Tickets

Regex Replace Modifier

Run a find and replace regex on a string of content.

message: 'This is a great video: https://www.youtube.com/watch?v=YO_spdAYjPk'
{{ message | regex_replace('watch\?v=[\w-]+', 'watch?v=dQw4w9WgXcQ') }}
{{ Statamic::modify($message)->regexReplace(['watch\?v=[\w-]+', 'watch?v=dQw4w9WgXcQ']) }}
This is a great video: https://www.youtube.com/watch?v=dQw4w9WgXcQ

Great for when your client keeps putting YouTube links in their content and you want to, uh, help them out.