Simon Strandgaard
1/25/2006 10:17:00 AM
On 1/25/06, diz rael <dizraelus@yahoo.com> wrote:
[snip]
> s =
> "5b3000ba00260bababababababababababababababababa000bd1007bd10b810ba92"
> p s.scan(/(?:ba){2,}|(?:[^b][^a])+/)
> => ["5b3000", "a00260",
> "bababababababababababababababababa",
> "000bd1007bd10b810ba9"]
>
> ideally, it should be:
> => "5b3000ba00260"
> "bababababababababababababababababa"
> "000bd1007bd10b810ba92"
Hmm.. the many ba's is at an odd offset.. don't you want them only at
equal offsets?
Maybe like this?
s = "5b3000ba00260bababababababababababababababababa000bd1007bd10b810ba92"
p s.scan(/\G(?: (?:ba)+ | (?:(?!ba)..)+ )/x)
# ["5b3000", "ba",
"00260bababababababababababababababababa000bd1007bd10b810", "ba",
"92"]
--
Simon Strandgaard