gcue Posted February 25, 2015 Share Posted February 25, 2015 hello world instead of using stringsplit, i am trying to see if there's a way to use stringregexp to extract date from a string $string = "12/21/2013 01:32:22 PM" I would like to keep "12/21/2013" thanks in advance! Link to comment Share on other sites More sharing options...
TheDcoder Posted February 25, 2015 Share Posted February 25, 2015 thanks in advance! Hey, Thats my style I am trying to learn regexp pattern's from here, Hope it Helps EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
jguinch Posted February 25, 2015 Share Posted February 25, 2015 $string = "12/21/2013 01:32:22 PM" ; $date = StringRegExpReplace($string, "^\d{2}/\d{2}/\d{4}\K.+", "") $date = StringRegExpReplace($string, "\h.+", "") ConsoleWrite($date) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
gcue Posted February 25, 2015 Author Share Posted February 25, 2015 perfect thank you! Link to comment Share on other sites More sharing options...
jguinch Posted February 25, 2015 Share Posted February 25, 2015 You can also easily do it without regex : $date = StringLeft($string, StringInStr($string, " ") - 1) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
kylomas Posted February 25, 2015 Share Posted February 25, 2015 or $string = "12/21/2013 01:32:22 PM" ConsoleWrite(stringsplit($string,' ',2)[0] & @LF) Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now