# How do I regex the output of a tag?

**URL:** <https://www.ruby-forum.com/t/how-do-i-regex-the-output-of-a-tag/136254>\
**Category:** Radiant CMS\
**Created:** [April 30, 2008, 4:42am UTC](https://www.ruby-forum.com/t/how-do-i-regex-the-output-of-a-tag/136254 "2008-04-30T04:42:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubella](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6a8cbe/32.png) [@rubella](https://www.ruby-forum.com/u/rubella)\
**Post date:** [April 30, 2008, 4:42am UTC](https://www.ruby-forum.com/t/how-do-i-regex-the-output-of-a-tag/136254/1 "2008-04-30T04:42:23Z")

</div>

Hi All,

I want to manipulate the contents of \<r:url /\> using regex. I’m  
wanting to do something like MovableType’s regex modifier for  
variables[1]:  
In MT-ese what I want to do is:  
\<mt:var tag=“pagepermalink”  
regex\_replace=“/^(.+)/ja/(.\*)/”,“$1/en/$2” /\>  
To change eg:  
[http://example.site/ja/optional/path](http://example.site/ja/optional/path)  
into:  
[http://example.site/en/optional/path](http://example.site/en/optional/path)

How would I do this? Is there a way to write ruby code directly into  
templates? Or am I looking at a custom Radius tag or making an  
extension?

Thanks in advance!

peace - oli

[1]

> **[MovableType.org – Documentation: regex\_replace](https://movabletype.org/documentation/appendices/modifiers/regex-replace.html)**
>
> Build your website with the powerful content management system Movable Type. Our blogging software and static publishing platform makes site management easy and effective.
