|
-
Dec 11th, 2003, 04:47 PM
#1
Thread Starter
Frenzied Member
Perl Q - 1/1/2003 to 2003
I how i format a date like this
01/01/2003
to
1/1/2003
??
Thanks!
-
Dec 15th, 2003, 07:42 AM
#2
Split it into components, ltrim all zeros and put it back together.
Or a smart regexp:
s/0*(\d+)\/0*(\d+)\/0*(\d+)/$1.'/'.$2.'/'.$3/e
maybe with the slashes escaped in the second part.
Last edited by CornedBee; Dec 15th, 2003 at 08:30 AM.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 16th, 2003, 01:22 PM
#3
Addicted Member
Or, instead of using backticks (which isn't bad):Mind you, I haven't tested that, and its been a couple months since I've done RegEx in Perl. It should look for a zero at the beginning of the string, or a slash zero and delete them (replace them with nothing).
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|