I have a little problem. I have “some text 23%”, but I need “some text ; 23%”, so I tried replacing ” ” for ” ; “.
I tried something like this:
"some text 23%".gsub /(\d+)%/, "; \0"
Problem is in response, in console it is ok, but when I use it in script I have:
"some text ; ^@"
And I don’t know what do with ^@ for have good value.
Thanks for help!
The following should work:
You can find more information about making back references to the captures in the ruby documentation: http://ruby-doc.org/core-1.9.3/String.html#method-i-gsub