# Re: Substituting from another file

**URL:** <https://www.ruby-forum.com/t/re-substituting-from-another-file/93864>\
**Category:** Ruby\
**Created:** [April 12, 2006, 3:49pm UTC](https://www.ruby-forum.com/t/re-substituting-from-another-file/93864 "2006-04-12T15:49:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [April 12, 2006, 3:49pm UTC](https://www.ruby-forum.com/t/re-substituting-from-another-file/93864/1 "2006-04-12T15:49:02Z")

</div>

I had resolved a similar problem some time ago by reading what  
corresponds  
to your dictionary data into a hash (i.e., {‘PANELED’ =\>‘P AE1 N AH0 L  
D’,  
‘PANELING’=\>“P AE1 N AH0 L IH0 NG”} ).  
I would then replace the keys by the values in the target text using  
gsub.  
Cave: actually, in my application, I also had to sort my keys for  
length, in  
case  
a word would be longer than another, but pronounced identically … you  
can do that by iterating over an array which you get from my\_hash.sort.

Best regards,

Axel
