in reply to Use Regular Expression to add spaces to a string

Any ideas?

The obvious way:

$oldstring = '123456789';; $oldstring =~ s[(...)(...)(...)][$1 $2-$3];; print $oldstring;; 123 456-789

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Use Regular Expression to add spaces to a string
by omegaweaponZ (Beadle) on Mar 26, 2012 at 22:34 UTC
    Winner goes to BrowserUk. This is extremely simple and intuitive. Does exactly what I need and is the easiest to form. Thanks!