Type: modifier
The regex_replace tag modifier is capable of performing complex string substitutions and manipulations using Regular Expressions.
The syntax is a little non-standard because this particular tag modifier takes two arguments: a pattern to match, and a string to replace it with. Both arguments are encapsulated by quotes and delimited with a comma as follows:
regex_replace="<pattern to match>","<replacement string>"
Example
The following will return the first letter only of the current page title:
<mt:PageTitle regex_replace="/(?<=^.).*$/","">
Special characters such as > can be expressed in a hexidecimal form:
<mt:PageTitle regex_replace="/\x3E/","...">
The following will replace all occurences of the term "Foo" with "Bar" in an entry body:
<mt:EntrySummary regex_replace="/Foo/","Bar">
As with other tag modifiers, you may repeat the regex_replace attribute multiple times for the same tag to apply multiple operations. And the order they appear will be the order they are applied to the tag.
Related
Submit a User Contributed Note
User contributed notes are a great way to share the knowledge you have gained in using Movable Type.
If you have a technical question or problem, please visit Movable Type Support.