User Profile

Collapse

Profile Sidebar

Collapse
markhu
markhu
Last Activity: Sep 23 '09, 12:08 AM
Joined: Aug 25 '09
Location: Los Angeles, CA
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • markhu
    replied to String manipulation for a date
    in Perl
    IMHO, unpack seems like a lot of extra work.

    Try this one-liner using regular expression:

    Code:
    $ perl -pi.bak -e 's/(....)(..)(..)T(..)(..)(..)/$1-$2-$3-$4.$5.$6.000000/' /tmp/junk.txt
    See more | Go to post
    Last edited by numberwhun; Aug 27 '09, 02:02 AM. Reason: Please use code tags!

    Leave a comment:


  • markhu
    replied to Javascript string functions
    the real way to do string slices

    There is no leftstr() or rightstr() functions in JavaScript because the slice() function handles both.

    Here is an example that shows the first 4 chars of a string, then the last 4.

    Code:
    x="sample string";
    
    r=x.slice(0,4) + ' : ' + x + ' : ' + x.slice(-4);
    
    alert( r );
    r will be "samp : sample string : ring"
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...