Question: I am having string:

```
str = "[[591, 184] , [741, 910] , [987,512], [2974, 174]]"

```

I want to convert this to an array:

```
arr = [[591, 184] , [741, 910] , [987,512], [2974, 174]]

```

How can i do this?

Answer: 
I would `split` and `scan` in two steps.

```
str = "[[591, 184] , [741, 910] , [987,512], [2974, 174]]"

str.split(/\]\s*,\s*\[/).map { |s| s.scan(/\d+/).map(&:to_i) }
  #=> [[591, 184], [741, 910], [987, 512], [2974, 174]]

```

Note that

```
str.split(/\]\s*,\s*\[/)
  # => ["[[591, 184", "741, 910", "987,512", "2974, 174]]"]  

```
You have to use "eval":

```
> str = "[[591, 184] , [741, 910] , [987,512], [2974, 174]]"
# => "[[591, 184] , [741, 910] , [987,512], [2974, 174]]"
> arr = eval str
# => [[591, 184], [741, 910], [987, 512], [2974, 174]] 

```