Please try these.

1. str.gsub(/\]\[/, '],[')

2. str.sub(/,$/, '')

Best regards,

JS

huseyin polat wrote:
> I have spend over 4 hours for this.. here is the question masters, very 
> simple.
> str=String.new
> str="[1,2][2,1][3,1][4,1]"
> 
> now I want to print this string as
> [1,2],[2,1],[3,1],[4,1]
> in other word I want to add comma between those ][ and make them look 
> like ],[
> I tried gsub with hundred different possibilities but no luck,
> 
> second problem
> if my the same str has
> [1,2][2,1][3,1][4,1],
> and I want to get rid of last comma from the list, I tried chop chomp 
> and all that but it gets ri of alot more than comma at the end. how can 
> I get rid of last comma from the list? from [1,2][2,1][3,1][4,1], to 
> [1,2][2,1][3,1][4,1]
> 
> 
> any help will be appreciated.
> thank you