我使用的问题gsub删除[],并\"从一个字符串.这是字符串:
"[\"This is a word ect\", \"Char2\", \"Another grooup\", \"Char4\"]"
Run Code Online (Sandbox Code Playgroud)
我希望返回值为:
"This is a word ect, Char2, Another grooup, Char4"
Run Code Online (Sandbox Code Playgroud)
谁能指出我正确的方向?
只是出于好奇:
str = '["This is a word ect", "Char2", "Another grooup", "Char4"]'
require 'json'
JSON.parse(str).join(', ')
#? "This is a word ect, Char2, Another grooup, Char4"
Run Code Online (Sandbox Code Playgroud)