regex_replace
Applies a regular expression operation on the input. This filter accepts two input values: one is the pattern, the second is the replacement.
Example:
<$mt:EntryTitle regex_replace="/\s*\[.+?\]\s*$/",""$>
This would strip any bracketed phrase from the end of the entry title field.
jeffschuler.sxipper.com
January 25, 2008 6:48 PM | Reply
Back-references:
Use $1, $2, $3, etc., in the replace field to echo the corresponding matched phrases within parentheses in the search field.
Dan Wolfgang
June 5, 2009 2:00 PM | Reply
Note that the "g" global modifier is valid here, which will find all occurrences, not just one. Extending the above example:
Beau Smith
June 23, 2009 9:43 PM | Reply
List entry categories if their label is within the set Explore, Savor, Inside, Offbeat, or Celebrate and then glue them with ", ". (The regex_replace modifiers remove extra glue from beginning, end, and between categories that don't match the if statement)
This is only here as an example, a much better solution would be to use mt:SevVarBlock with function="push" attribute and then output with mt:Loop
Beau Smith
November 17, 2009 11:33 AM | Reply
Search for case-insensitive "the" with optional spaces on either side and replace with nothing. Then dirify the result.
Thus if the blog name was "The Big Lebowski", it would be converted to "big-lebowski".
Beau Smith
November 28, 2009 2:37 AM | Reply
If blog description is:
Use this
regex_replaceto get the part in parenthesis:Output will be:
Beau Smith
December 1, 2009 12:18 PM | Reply
Remove the "http://www" from a url:
Beau Smith
December 10, 2009 12:14 PM | Reply
RegExr is a tool for learning, testing, sharing regular expressions. (desktop version also available)
Gercek Karakus
December 10, 2009 4:24 PM | Reply
Remove the ".html" from the entry permalink:
indieangler
replied to comment from Beau Smith
April 9, 2010 11:18 AM | Reply
Hi Beau,
I'm trying to use the container tag to create a list of parent categories such as: Food/Italian/Pizza/Pepperoni and then apply a regexreplace to pull the name of the 2nd Category. So in that list, the regexreplace would return "Italian". I've tried so many variations and it's starting to do my head in. Can you recommend a solution to pull that 2nd category name with this method? I just can't seem to get it working.
Gercek Karakus
April 22, 2010 8:12 AM | Reply
If you want to replace the "-" with "_" in your category label: