Question: I have strings in an array:

```
["foo","bar","foo"bar"baz"]

```

I am using `eval` method to form an array with this string, but the inner double quotes are not escaped:

```
eval('["foo","bar","foo"bar"baz"]') # => SyntaxError

```

Is there a way to escape only the ones inside an array element?

Answer: 
I think you can try something like

```
eval('["foo","bar","foo"bar"baz"]'.gsub(/(\w)\"(\w)/, '\1\"\2'))

```

if I got what you have meant
This might work for all possible variants. This would fix all quotes except of appearing near commas and brackets

```
.gsub(/(?<!\,)(?<!\[)(?<!\])\"(?!\,)(?!\[)(?!\])/, '\"')

```