Hi,
Need regex expression for both of these.
02/13/2022 and 09:30:00
How to differentiate between them .
Hi,
Need regex expression for both of these.
02/13/2022 and 09:30:00
How to differentiate between them .
Try this expression to get both the values in single expression
System.Text.RegularExpressions.Regex.Match(InputStr,"\d.{2}\d.{2}\d{2,4}").Tostring
Try this expression to get Date values
System.Text.RegularExpressions.Regex.Match(InputStr,"\d.{2}\d.{2}\d{4}").Tostring
Regards
Gokul
Simple pattern with options:
Advanced with Group Names:
So based on the group name we can retrieve which case we got
Hi @shirin.sebatina ,
Here is an interesting take on this subject, but I guess ppr has beaten me to it!
Basically, you have the option of assigning names to “groups” of matches.
Here is one such example →
(?<date>\d+\/\d+\/\d+).*?(?<time>\d+\:\d+\:\d+)
System.Text.RegularExpressions.Regex.Matches(str_DateandTime,"(?<date>\d+\/\d+\/\d+).*?(?<time>\d+\:\d+\:\d+)")
And that allows you to do something amazing like this →
matches.Item(0)
matches.Item(0).Groups("date")
matches.Item(0).Groups("time")
Really beautiful stuff, I’d recommend you give it a try.
Kind Regards,
Ashwin A.K