If a have a string like:
"_test_teste2 _test3"
how can I add a space before the _ that don't have a space before already and are not in the start of the string?
Ex:
"_test _teste2 _test3"
I tried this:
todo.desc = todo.desc.gsub /_/, " _"
It works, but add spaces after every _.
Thanks in advance.
>> "_abc_de _e _f_tes_fefe".gsub(/(\S)_/,'\1 _')
=> "_abc _de _e _f _tes _fefe"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With