Str_replace PHP Function Equiv

I’ve been searching for ages and not come up with anything on the
internet. I was wondering if there is a Rails equiv. for the PHP
function str_replace. For example;

variable_for_new_string(“value_to_repace”, “string_to_replace_with”,
“string_to_perform_modification_to”)

Thanks in advance for any help.

Hey,

The ruby equiv of str_replace is gsub.

So

“Hello World”.gsub(“Hello”, “Bye”)

http://corelib.rubyonrails.org/classes/String.html#M001538

~Rohith

Thanks, i’ve managed to get my helper working correctly now.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs