String manipulation for a date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #16
    Originally posted by nithinpes
    Jeff's command should have been:

    Code:
    perl -pi.bak -e 's/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})/$1-$2-$3-$4.$5.$6.000000/' /tmp/junk.txt
    \d{,4} will set an upper limit of 4 occurences for digits(max. 4 digits) and not exact 4 occurences as in \d{4} (which is appropriate for the given sample data).
    See, that's why I included the "if". I couldn't remember right off if the comma should be there or not and couldn't get up the energy to dig for my reference sheet. Thanks!

    Jeff

    Comment

    Working...