I hate to ask another “how do you do this with regex” question on here…there seem to be a lot of them. But, I am struggling with this.
I am working in C#, and I need to correct a datetime string before I convert it from a string to a DateTime datatype variable. My string looks like this:
2012-01-24T17-52-08Z
I need to replace the “-” characters that occur after the “T” with colons, so it will look like this:
2012-01-24T17:52:08Z
I have tried to adapt the code from this example but, to no avail. I have been using this wonderful tool to try to get this working.
I know this will be simple to someone who regularly works with RegEx but, I work with it so rarely that I forget most of what I learned before I get a chance to use it again.
Thanks for any help you can give.
Can you try matching with
(\d{4}-\d{2}-\d{2}T\d{2})-(\d{2})-(\d{2})Zand replacing with
$1:$2:$3Z