Skip to main content


<r:replace />

This tag uses regular expressions to replace the content inside the tag with whatever characters you specify.

Attribute Options:

  • match - The regular expression pattern to use to match what characters to replace. String.
  • with - The characters to replace what was matched in the match attribute. String.


<r:replace match="WordPress" with="CleanSlate">
  WordPress is the best CMS.
<!-- Output: "CleanSlate is the best CMS." -->
<!-- RegEx matches any digit -->
<r:replace match="\d" with="A">123</r:replace>
<!-- Output: "AAA" -->
<!-- Regex to grab individual strings, sans commas and spaces -->
<!-- Regex from: -->
<r:replace match="[^,\s][^\,]*[^,\s]*" with="Renamed tag">
  tag_1, tag 2, label-3, example
<!-- Output: "Renamed tag, Renamed tag, Renamed tag, Renamed tag" -->

{{ "Hello World" | replace: "Hello", "Hi" }}

Replaces every occurrence of the first argument in a string with the second argument.

View the official Liquid documentation for the replace filter.


{{ "Wordpress is the best CMS" | replace: "Wordpress", "CleanSlate" }}
<!-- Output: "CleanSlate is the best CMS." -->
<!-- Input: = "Wordpress is the best CMS" -->
{{ | replace: "Wordpress", "CleanSlate" }}
<!-- Output: "CleanSlate is the best CMS." -->
{{ "Morgantown is located in Morgantown, WV." | replace_first: "Morgantown", "WVU" }}
<!-- Output: "WVU is located in Morgantown, WV." -->

Note: Liquid does not support Regular Expressions (RegEx) due to security reasons. It does have a wide variety of Filters that can likely suit your needs.

Last updated on March 16, 2021.

We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:

  • A brief description of the issue
  • A link to the page where you saw the issue
  • Screenshots that illustrate the problem - How do I take a screenshot?

Kindly email for help or use the form on the request help page.