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']) }}
Check out this video: https://www.youtube.com/watch?v=eBGIQ7ZuuiU
Great for when your client keeps putting YouTube links in their content and you want to, uh, help them out.