From: "Peña, Botp" Date: 2007-07-24T10:50:26+09:00 Subject: Re: finding positions in a string From: bwv549 [mailto:jtprince@gmail.com] # substring_positions(my_substring, my_string) # -> should return # [0, 12, 29] # # This seems trivial to do, but looking at StringScanner, String#match, # and String#scan, nothing simple comes to mind. There must be a one- # liner somewhere for this kind of thing. not a raw one-liner, but you can create one ;) root@pc4all:~# cat -n test.rb 1 class String 2 def scan_p ss 3 a = [] 4 self.scan(ss){a << Regexp.last_match.begin(0)} 5 a 6 end 7 end 8 9 p "this string this is a string this is it".scan_p("this") 10 root@pc4all:~# ruby test.rb [0, 12, 29] root@pc4all:~# i think the keyword is Matchdata. kind regards -botp