Search code examples
regextypesmovable

Movable Type: Change URL using regex replace


In my <mt:EntryBody> text I have few urls which I want to change the pointing address.

http://www.myblog.com/blog/content/fruit/apple.html

to

http://www.myblog.com/blog/apple/

In this case word "fruit" and "apple" would be the variable. I would like to use regex_replace modifier to change every URL in EntryBody.

How would I write this?


Solution

  • Try this ?

    <mt:EntryBody regex_replace="/content\/\w*\/([^\.]*)\.html/","$1/">
    

    $1 will get the info from what matched inside "( )"