# Problem with gSubing

**URL:** <https://www.ruby-forum.com/t/problem-with-gsubing/128742>\
**Category:** Rails\
**Created:** [February 11, 2008, 6:42am UTC](https://www.ruby-forum.com/t/problem-with-gsubing/128742 "2008-02-11T06:42:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohit\_ranka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@mohit\_ranka](https://www.ruby-forum.com/u/mohit_ranka)\
**Post date:** [February 11, 2008, 6:42am UTC](https://www.ruby-forum.com/t/problem-with-gsubing/128742/1 "2008-02-11T06:42:02Z")

</div>

Hi,  
I am trying to this using gsub.

\<- Variable\_Name -\> ==\> \<%= Variable\_Name %\>

Currently, I am doing it by changing the \<- to \<%= and -\> to %\>  
separately… but I need to do it as whole… as gsub (\<- some\_text -

> ) ==\>(\<%= some\_text %\>)

I hope i am clear!

Thanks and regards,  
Mohit

---

<div class="post-metadata">

**Author:** ![mohit\_ranka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/898d66/32.png) [@mohit\_ranka](https://www.ruby-forum.com/u/mohit_ranka)\
**Post date:** [February 11, 2008, 7:11am UTC](https://www.ruby-forum.com/t/problem-with-gsubing/128742/2 "2008-02-11T07:11:21Z")

</div>

string.gsub(/\<-(.\*?)-\>/,’\<%=’ + $1 + ‘%\>’)
