From: Justin Collins Date: 2006-08-03T03:04:23+09:00 Subject: Re: How to split(//) with respect to bigraphs? Pavel Smerk wrote: > And once more question: > > In Czech, c followed by h is considered (for sorting etc.) as one > character/grapheme ch. I need to split string to single characters > with respect to this absurd manner. > > In Perl I can write > > split /(?<=(?![Cc][Hh]).)/, $string > > and it works fine. > > Unfortunately, Ruby does not implement/support this "zero-width > positive look-behind assertion", so the question is how can one > efficiently split the string in Ruby? > > Thanks, > > P. > Does this work? irb(main):001:0> "czech".split(/([Cc][Hh])|/) => ["c", "z", "e", "ch"] irb(main):002:0> "check czech".split(/([Cc][Hh])|/) => ["", "ch", "e", "c", "k", " ", "c", "z", "e", "ch"] irb(main):003:0> "cHeck czeCh".split(/([Cc][Hh])|/) => ["", "cH", "e", "c", "k", " ", "c", "z", "e", "Ch"] -Justin