Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Space between digits

by tobyink (Abbot)
on Nov 21, 2012 at 21:23 UTC ( #1005012=note: print w/ replies, xml ) Need Help??


in reply to Space between digits

use 5.014; my $string = "0:00 11/21/2012"; my $new = $string =~ s/ / /r; say $string; say $new;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Space between digits
Download Code
Re^2: Space between digits
by Anonymous Monk on Nov 21, 2012 at 21:28 UTC
    I meant for that pattern and of date and time. I didnt mean that particular string. for example for the pattern
    (\d+)\:(\d+) (\d+)\/(\d+)\/(\d+)
    how do I triple the space between the time and date ?

      The code I posted will work on any string. It finds the first space and replaces it with three spaces.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
        The code you gave is not working I tried this
        if ($_ =~ m/(\d+)\:(\d+) (\d+)\/(\d+)\/(\d+)/ ){ my $string = "(\d+)\:(\d+) (\d+)\/(\d+)\/(\d+)"; my $new = $string =~ s/ / /; print "new $new "; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005012]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-05 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls