I want i check the format of timestamp which is described in RFC3339.
Here is the examples:
"1996-12-19T16%3A39%3A57-08%3A00"
"1996-12-19T15%3A39%3A27%2E20-08%3A00"
"2013-07-08T18%3A07%3A13Z"
"2013-07-08T18%3A07%3A13.49Z“
I have run one re pattern, but it only works for the first and second examples.
"\\d{4}-\\d{2}-\\d{2}T\\d{2}%3A\\d{2}%3A\\d{2}(%2E\\d+)?[+-]\\d{2}%3A\\d{2}"
The below regex would match all the above four examples,
"^\\d{4}-\\d{2}-\\d{2}T\\d{2}%3A\\d{2}%3A\\d{2}(?:%2E\\d+)?[A-Z]?(?:[+.-](?:08%3A\\d{2}|\\d{2}[A-Z]))?$"
DEMO
You forget to mark [+-]\\d{2}%3A\\d{2}
as optional and also forget to add regex to match Z
and .49Z
in third and fourth line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With