SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regex match a date

    Hi,
    Code JavaScript:
    var str = 'date-2010-06-08';
    var re = /(\d{4})-(\d{2})-(\d{2})/;
    var found = str.match(re);
    alert(found[0]);

    Is there a better way ?

    Thanks in advance.

    Bye.

  2. #2
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    var str = 'date-2010-06-08';
    var re = /(\d{4})-(\d{2})-(\d{2})/g;
    var found = str.match(re);
    alert(found);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •