From: Harry Kakueki Date: 2007-06-03T14:20:33+09:00 Subject: Re: No way of looking for a regrexp match starting from a particular point in a string? On 6/3/07, Harry Kakueki wrote: > On 6/3/07, Kenneth McDonald wrote: > > > > What I want is just something like regexp.match(string, n), where the > > regexp starts looking for a match at or after position n in the string. > > > > > > Thanks, > > Ken > > > > > > You could match the string but ignore the first part of the match. > > str = "abcdefghabcehjjjuabcfjkiabcgdfg" > str =~ /(abc.)/ > p $1 # abcd > str =~ /a.*ju(abc.)/ > p $1 #abcf > > Harry > If you want to specify the point in the string by number, you could do this. str = "abcdefghabcehjjjuabcfjkiabcgdfg" str =~ /.{10}(abc.).*(abc.)/ p $1 #abcf p $2 #abcg Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/