omegaweaponZ has asked for the wisdom of the Perl Monks concerning the following question:
I'm still a newbie when it comes to regular expressions. I'm OK with matching and replacing strings, but I'm trying to use re's to take a single string and add spaces to it. See example below:
$oldstring = '123456789'
-- regular expression function --
$newstring = '123 456-789'
Any ideas? I'm assuming it's based on counting characters based on .. as those characters will constantly change, but the order in which I need them to add a space or - will not
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use Regular Expression to add spaces to a string
by BrowserUk (Patriarch) on Mar 26, 2012 at 20:54 UTC | |
by omegaweaponZ (Beadle) on Mar 26, 2012 at 22:34 UTC | |
|
Re: Use Regular Expression to add spaces to a string
by petdance (Parson) on Mar 26, 2012 at 21:42 UTC | |
|
Re: Use Regular Expression to add spaces to a string
by johngg (Canon) on Mar 26, 2012 at 21:54 UTC | |
|
Re: Use Regular Expression to add spaces to a string
by JavaFan (Canon) on Mar 26, 2012 at 23:23 UTC |