irb(main):005:0> a=“123-456-1239”
=> "123-456-1239"
irb(main):006:0> a[/123/, 2]="xxx"
IndexError: index 2 out of regexp
from (irb):6:in []=' from (irb):6 irb(main):007:0> a[/123/, 1]="xxx" IndexError: index 1 out of regexp from (irb):7:in[]='
from (irb):7
irb(main):008:0> a
=> “123-456-1239”
I tested this in IRB and it seems work just fine. I don’t know if
there’s a more efficient way to do
this that is less complex looking but it does work. Let me know if you
need help decoding this regexp,
but I think it’s fairly self explanatory.
Yan
Rob Partington wrote:
···
This is good stuff. Except it doesn’t extend.
irb(main):005:0> a=“123-456-1239”
=> “123-456-1239”
irb(main):006:0> a[/123/, 2]=“xxx”
IndexError: index 2 out of regexp
from (irb):6:in []=' from (irb):6 irb(main):007:0> a[/123/, 1]="xxx" IndexError: index 1 out of regexp from (irb):7:in =’
from (irb):7
irb(main):008:0> a
=> “123-456-1239”