Hello all,
i am trying to get time from a string. so need to regex to get the time from it.
input string is : EXPECTED DELIVERY DATE | 3/7/23 AT 8:00 AM - 9:00 AM
need to extract 8:00 AM - 9:00 AM.
so can you please help me on this?
Hello all,
i am trying to get time from a string. so need to regex to get the time from it.
input string is : EXPECTED DELIVERY DATE | 3/7/23 AT 8:00 AM - 9:00 AM
need to extract 8:00 AM - 9:00 AM.
so can you please help me on this?
Hi @sudha456 ,
Use this below code,
YourStr(String as data type) = System.Text.RegularExpressions.Regex.Match("EXPECTED DELIVERY DATE | 3/7/23 AT 8:00 AM - 9:00 AM","\d{1}\:\d{2}\s+[A-z]{2}\s+\-\s+\d{1}\:\d{2}\s+[A-z]{2}").Value
Hope this might help you
Split(“EXPECTED DELIVERY DATE | 3/7/23 AT 8:00 AM - 9:00 AM”," ").Last()
Hey @sudha456
Assign strDate = System.Text.RegularExpressions.RegEx.Match(StrVariable,“\d{0,}:\d{0,}\s\w{2}\s-\s\d{0,}:\d{0,}\s\w{2}”).ToString
Cheers.
Hi @sudha456
How about this regular expression
System.Text.RegularExpressions.Regex.Match(YourString,"\d{1,2}:\d{1,2} (AM|PM)").Tostring
Thank you all for your quick response.
Hi @sudha456 ,
Maybe an alternate Regex Expression with specificity :
\d{1,2}\:\d{1,2}\s(AM|PM)\s-\s\d{1,2}\:\d{1,2}\s(AM|PM)
Expression :
System.Text.RegularExpressions.Regex.Match("EXPECTED DELIVERY DATE | 3/7/23 AT 8:00 AM - 9:00 AM","\d{1,2}\:\d{1,2}\s(AM|PM)\s-\s\d{1,2}\:\d{1,2}\s(AM|PM)",System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value.Tostring
Hi @sudha456 Try the below expression
System.Text.RegularExpressions.Regex.Match(Input,"\d:\d+\s+[A-Z]{1,2}\s+-\s+\d:\d+\s+[A-Z]{1,2}").ToString
Refer the below workflow
Test.zip (2.1 KB)
Hello All,
thanks a lot for your quick responses.
facing issue when inout string changes a bit. given regex is unable to get us the time.
input string formats are :
1.ON 3/6/23 AT 10:23 AM - 10:36 AM
2.EXPECTED DELIVERY DATE | 3/7/23 AT 8:00 AM - 9:00 AM
may i have regex which give us the time please?
expected time is 8:00 AM - 9:00 AM
@sudha456 Try the below one it is working for both the cases
System.Text.RegularExpressions.Regex.Match(Input,"\d+:\d+\s+[A-Z]{1,2}\s+-\s+\d+:\d+\s+[A-Z]{1,2}").ToString
Hi @sudha456, here is the regex,
(?<=AT\s)\d{1,2}:\d{2}\s[AP]M\s-\s\d{1,2}:\d{2}\s[AP]M
Thanks a lot for you time and response. it worked .
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.