# String indexing/setting

**URL:** <https://www.ruby-forum.com/t/string-indexing-setting/70540>\
**Category:** Ruby\
**Created:** [September 29, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/string-indexing-setting/70540 "2006-09-29T22:03:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevenreplica](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@stevenreplica](https://www.ruby-forum.com/u/stevenreplica)\
**Post date:** [September 29, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/string-indexing-setting/70540/1 "2006-09-29T22:03:38Z")

</div>

I think I found a version difference between 1.82 and 1.84-20 Stable and  
I  
wanted to know what correct code was and what was not.

pos = s.index(“11”)

s = “000011481^3”

s[2…pos] = “BigString”

puts s

On one server I have 1.82 and it generates “00BigString1481^3” on  
another  
with 1.84-20 it generates “00BigString”. However, on a third server I  
have  
a 1.84 version that puts out a similar version as the 1.82.

These are all Windows machines.

What should I be expecting?

Thanks!

---

<div class="post-metadata">

**Author:** ![stevenreplica](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@stevenreplica](https://www.ruby-forum.com/u/stevenreplica)\
**Post date:** [September 29, 2006, 11:07pm UTC](https://www.ruby-forum.com/t/string-indexing-setting/70540/2 "2006-09-29T23:07:43Z")

</div>

Steven K. wrote:

> I think I found a version difference between 1.82 and 1.84-20 Stable and I  
> wanted to know what correct code was and what was not.
> 
> pos = s.index(“11”)

what is ‘s’ here?

> s = “000011481^3”
> 
> s[2…pos] = “BigString”
> 
> puts s

cheers

Simon

---

<div class="post-metadata">

**Author:** ![stevenreplica](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@stevenreplica](https://www.ruby-forum.com/u/stevenreplica)\
**Post date:** [September 29, 2006, 11:11pm UTC](https://www.ruby-forum.com/t/string-indexing-setting/70540/3 "2006-09-29T23:11:44Z")

</div>

Sorry! Wrong order in the copy-and-paste.

s = “000011481^3”  
pos = s.index(“11”)  
s[2…pos] = “BigString”

puts s

Thanks!

Steve
