Remove time from calendar schedule string

I have this text that I extracted from outlook “Saturday, October 14, 2023 8:00 AM-9:00 AM”

What’s the best way to dynamically remove the time so that it’ll just be “Saturday, October 14, 2023”?

Hi @mj.work

You can try with Regular expression

System.Text.RegularExpressions.Regex.Match(YourString,"\S+,\s\S+\s[0-9]+").Tostring

image

1 Like

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Replace(yourString,"(?<=\d{4}).*","")

regards,

1 Like

@mj.work

Please try this

\w+, \w+ \d+, \d+

System.Text.RegularExpressions.Regex.Match(str,"\w+, \w+ \d+, \d+").Value

cheers

Hi @mj.work

Checkout this

System.Text.RegularExpressions.Regex.Match(INputString,"(.*?)\d{4}").Tostring

image

Regards
Sudharsan

Is there a way to remove Saturday to get “October 14, 2023”?

Check with this @mj.work

System.Text.RegularExpressions.Regex.Match(INputString,"(?m)(?<=\,)(.*?)\d{4}").Tostring.Trim

image

Regards
Sudharsan

Hi @mj.work

Check out the Regular expression

System.Text.RegularExpressions.Regex.Match(INputString,"\S+\s\d{2}\W\s\d{4}").Tostring.Trim

image

@mj.work

System.Text.RegularExpressions.Regex.Match(str,“[a-zA-Z]+\s\d{2}.\s\w+\d{2}”).Value

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.