Regex for invalid date formats
Thread poster: Sakkko

Sakkko
Portugal
Nov 28, 2017

I've been trying to build a regex that allows me to verify if there's any invalid date formats on my translation - so far, after knudging a bunch of sphagetti code together, I have what it looks like something that checks if the date format is CORRECT. I want the opposite.
Here's my regex :

^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$


I'm completely lost right now in the midst of this mess. How can I make it so that it is easy for me to search for invalid date formats in my document? Should I just leave it this way and basically see if it detects all dates on my file (if there's any missing, it means they're in a wrong format) ?

Any help is greatly appreciated!


Direct link Reply with quote
 

Nora Diaz  Identity Verified
Mexico
Local time: 13:49
Member (2002)
English to Spanish
+ ...
What is the correct format? Nov 28, 2017

Hi Sakko,

That's a long expression! What is the correct date format you need?


Direct link Reply with quote
 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Regex for invalid date formats

Advanced search







BaccS – Business Accounting Software
Modern desktop project management for freelance translators

BaccS makes it easy for translators to manage their projects, schedule tasks, create invoices, and view highly customizable reports. User-friendly, ProZ.com integration, community-driven development – a few reasons BaccS is trusted by translators!

More info »
WordFinder Unlimited
For clarity and excellence

WordFinder is the leading dictionary service that gives you the words you want anywhere, anytime. Access 260+ dictionaries from the world's leading dictionary publishers in virtually any device. Find the right word anywhere, anytime - online or offline.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search