On Thu, Jan 31, 2002 at 09:53:00PM -0500, Jason Purdy wrote:
> This will not work (the . will match the /'s and preface them with 
> 0's)... try \d instead:

Yeah, you're right -- a hurried mispaste :-/

> $ perl -e '$a="9/9/1973\n";$a=~s/\b(.)\b/0$1/g;print $a;'
> 090/090/1973

This is odd, I get,

$  perl -e '$a="9/9/1973\n";$a=~s/\b(.)\b/0$1/g;print $a;'
09/09/1973
$

Debian's Perl 5.6.1. That . should indeed match the / AFAICS; I'm not
sure why it isn't here. What does everyone else get?

> $ perl -e '$a="9/9/1973\n";$a=~s/\b(\d)\b/0$1/g;print $a;'
> 09/09/1973
> $ perl -e '$a="9/09/1973\n";$a=~s/\b(\d)\b/0$1/g;print $a;'
> 09/09/1973
> 
> I would use printf's, tho, even tho I love regexps. :)

'Me too :-)' x 2;

Paul (whose other post contained the canonical sprintf version)

> 
> Jason
> 
> ----- Original Message ----- 
> From: "Paul Makepeace" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, January 31, 2002 8:47 PM
> Subject: Re: substitution question
> 
> 
> > On Thu, Jan 31, 2002 at 05:41:15PM -0800, Pradeep Sethi wrote:
> > > Thanks but I am looking of any regexp substitution.
> > > 
> > > sorry for typo : I need to change 9/9/1973 to 09/09/1973
> > 
> > How about,
> > 
> > s/\b(.)\b/0$1/g
> > 
> > Paul
> > 
> 

-- 
Paul Makepeace ....................................... http://paulm.com/

"If god is blue, then get going!"
   -- http://paulm.com/toys/surrealism/

Reply via email to