Re: Simple regex question
- From: "zzzhc" <zzzhc.starfire@xxxxxxxxx>
- Date: 27 Nov 2006 21:31:31 -0800
s/^(\d)$/0$1/;
"Bryan 写道:
"
Hi,
If I have this:
my $v1 = "9"; #Needs to be "09"
my $v2 = "01"; # Okay
my $v3 = "3"; # Needs to be "03"
my $v4 = "54"; #Okay
I want to make sure that all strings have the same format, which is 2
digits (or more) but that single digit values are padded with a '0'.
This is for a database query that happens later.
What is the regex to convert "1" to "01" and leaves "101" alone?
.
- References:
- Simple regex question
- From: Bryan
- Simple regex question
- Prev by Date: Re: run a perl program using actviveperl
- Next by Date: FAQ 3.3 Is there a Perl shell?
- Previous by thread: Re: Simple regex question
- Next by thread: FAQ 1.13 Is it a Perl program or a Perl script?
- Index(es):
Relevant Pages
|