On Sep 17, Jeff 'japhy' Pinyan said: >On Sep 17, NYIMI Jose (BMB) said: > >>Let say the known length is 2. >>If the string is 'abcd', my array should be ('ab', 'dc') >>And if my string is 'abcdef', my array should be ('ab', 'dc', 'ef'). > >I'd just use: > > @groups = $string =~ /../g; # use ... for three, or .{3}, etc. > >You don't need capturing parens in this case.
Although it should probably be /../gs, since . doesn't match newlines by default. And following the lead of other regex solutions, you could use the .{1,$x} approach. @groups = $string =~ /.{1,$x}/gs; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]