I wondering if there is a string replace function.
I have a string that looks something like:
and what I am looking to do is to replace the [W_PHONE], for example,
with 555-555-5555. What I have right now in terms of code is something
if /[W_PHONE]/ =~ 2YP/P:[CTYCODE]B/[W_PHONE]/F/[W_FAX]/R/[H_PHONE]
@var = "555-555-5555
which works but it builds a new string, which is fine, but the above
string could be constructed any number of ways - with another variable
string to replace on, or with one missing, etc. What I would really like
to do is replace the string in-place of the one that I am searching for.
Is there a built in ruby function to do this or can someone gets me some
pointers about writing one myself? Thanks,