From: Brian Candler Date: 2008-11-28T01:55:47+09:00 Subject: Re: reg exp Hai anh Le wrote: > I have another example as: > > "The coefficients are then mixed with the data from mixer 51xy, so that > the recording equipment 14abc stores the six channel data stream, the > scripting data 26aa and 27ac" > > My purpose is to find the position of number have style "123abc", after > that I get the string from begin to that position like "The coefficients > are then mixed with the data from mixer 51xy," > Then I will continued search... > > My code like > > while string.size do > if string=~ /.../ then > temp_string = $` + $& > string.gsub!(temp_string, "") > else > break > end > > > So that what I need is $& = "123abc" and not = "123abc and 123abc" Sorry - that still does not make it clear what you want, especially with the portion of the string " ... the scripting data 26aa and 27ac" Here is some code: str = <