gcue Posted February 25, 2015 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!
TheDcoder Posted February 25, 2015 Posted February 25, 2015 On 2/25/2015 at 5:04 PM, gcue said: 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
jguinch Posted February 25, 2015 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) Reveal hidden contents Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
jguinch Posted February 25, 2015 Posted February 25, 2015 You can also easily do it without regex : $date = StringLeft($string, StringInStr($string, " ") - 1) Reveal hidden contents Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
kylomas Posted February 25, 2015 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
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