Paul

Another option you may like, which uses the convenient way that Perl
stringifies arrays, with a space between each pair of elements.

It does mean that you need a temporary array variable though:

    my @a = split "", "2329238023089823";
    print "@a";

will output

    2 3 2 9 2 3 8 0 2 3 0 8 9 8 2 3

which I think is just what you want.

BTW, note that using s/(.)/$1 /g will leave you with a trailing space, which
almost certainly doesn't matter.

Cheers,

Rob


----- Original Message -----
From: "Paul Murphy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 28, 2002 1:33 PM
Subject: Repeating Regexp


>
>
> Hello, this is a two part question: a how to, and a how best to.
>
> I have a string of numbers:
>
> "2329238023089823"
>
> And I want insert a space after each number.  I can see how to insert
> after the first:
>
> s/(\d)/$1 /
>
> Can any one tell me how I can get the regexp to continue through the
> string and insert spaces throughout?
>
> The next part of the question is, given the above string, what is the
> best way of displaying the string with the added spaces, without
> necessarily altering it in the variable?
>
> So if the first part of the question is answered, then that is one way of
> doing it, but are there better ways (there are *always* better ways :-) )?
>
> Thanks,
>
> Paul.
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to