From: diz rael Date: 2006-01-25T18:40:44+09:00 Subject: Re: subsequence regular expression Thanks a lot for the suggestions. This is close to what I'm looking for, but I don't quite get the effect of "?:" The docs say that it simply makes the regexp into a group without generating backreferences. Doesn't this mean that *not* using ?: will only have the side-effect of setting $1, $2, etc. However,: p s.scan(/(ba){2,}|([^b][^a])+/) => [[nil, "60"], ["ba", nil], [nil, "a9"]] Another thing is that in the sample string in my original post, the first "ba" happens to occur on an odd location (string indexed from 0). If I shift it forward by a character it doesn't work as well: s = "5b3000ba00260bababababababababababababababababa000bd1007bd10b810ba92" p s.scan(/(?:ba){2,}|(?:[^b][^a])+/) => ["5b3000", "a00260", "bababababababababababababababababa", "000bd1007bd10b810ba9"] ideally, it should be: => "5b3000ba00260" "bababababababababababababababababa" "000bd1007bd10b810ba92" Thanks in advance.. --- Simon Strandgaard wrote: > s = > "5b300ba00260bababababababababababababababababa000bd1007bd10b810ba92" > p s.scan(/(?:ba){2,}|(?:[^b][^a])+/) > #["5b300ba00260", > "bababababababababababababababababa", > "000bd1007bd10b810ba9"] > > > -- > Simon Strandgaard __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com