Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果 a 有如下字符串:
“_test_teste2 _test3”
如何在之前_没有空格且不在字符串开头的空格之前添加空格?
_
前任:
“_test _teste2 _test3”
我试过这个:
todo.desc = todo.desc.gsub /_/, " _"
它有效,但在每个_.
提前致谢。
>> "_abc_de _e _f_tes_fefe".gsub(/(\S)_/,'\1 _') => "_abc _de _e _f _tes _fefe"