in reply to Re^2: How can I replace space sequences in a string with the number of spaces in each sequence?
in thread How can I replace space sequences in a string with the number of spaces in each sequence?

I would nest regexes by calling a function on each 8block.

How would you implement it ?

update

Or

  • split 8 blocks to array
  • replace whitespace for each element
  • join array with separator

    Can be done in a one liner with map .

    Cheers Rolf

    PS: Je suis Charlie!

    • Comment on Re^3: How can I replace space sequences in a string with the number of spaces in each sequence?
  • Replies are listed 'Best First'.
    Re^4: How can I replace space sequences in a string with the number of spaces in each sequence?
    by tkguifan (Scribe) on Feb 04, 2015 at 15:39 UTC
      This is tested:
      my $fen=join('/', map { $_=~s/( +)/length $1/ge; $_; } $self->{rep}=~/.{8}/g );
        you might be interested in the new /r flag to avoid adding $_ explicitly at the end of map.

        my $fen= join '/', map { s/( +)/length $1/ger } $input =~ /.{8}/g;

        Cheers Rolf

        PS: Je suis Charlie!