G'day.

$string =~ s/(.{4})(?=.)/$1 /g;

FYI, the ?= at the end is a zero-width look ahead assertion that stops a
space from being inserted after the last 4 chars. Please see 'perldoc
perlre' for details.

Mark.

On Fri, 2004-08-27 at 05:51, JP wrote:
> I am trying to split up a given string of unknown length with spaces at a
> given interval.
> 
> eg.:
> 
> $length=4;
> $string="MIICWwIBAAKBgQDGz8+vl9M4z0a0f/slusZ+mkBO7c9QuiV7yNAlBPiXZv8E/6yX";
> 
> should become:
> 
> $new_string="MIIC WwIB AAKB gQDG z8+v l9M4 z0a0 f/sl usZ+ mkBO 7c9Q uiV7
> yNAl BPiX Zv8E /6yX"
> 
> in  this example I used 4 character groups, in reality it will be 40
> characters or so.
> 
> Any usefull hints are welcome.
> 
> JP
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to