in reply to Splitting a String into n-character parts, without using a regex

You say without using a regex, but do you know that you can use //g in a list context to return all the matches at once? @row = 'aabbccddee' =~ /\w{2}/g; I use this approach a lot, because it's simple but powerful.
  • Comment on Re: Splitting a String into n-character parts, without using a regex
  • Download Code

Replies are listed 'Best First'.
Re^2: Splitting a String into n-character parts, without using a regex
by ndixon (Initiate) on May 06, 2005 at 09:09 UTC
    That approach works in this case; but for general strings, it would miss the last part of the string if it's too short (ie. less than 2 \w chars).
    @row = 'aabbccddee' =~ /\w{1,2}/g;
    will capture the last section too