Copy link to clipboard
Copied
I'm building a master template with paragraph and GREP styles. As mentioned in a previous post, I am an extreme novice when it comes to GREP but I am learning and, thankfully, some of it is starting to sink in.
My next problem is keeping dates from breaking. The dates could be in both dd month yyyy, or dd month. I also have the added spice of several languages being used so I'm trying to cater for all. I've gone through a few different versions and thought I was getting close to a simple solution with this expression;
\d+ ((?# ENG)January|February|March|April|May|June|July|August|September|October|November|December|(?# FRE)janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre|(?# SPA)enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|(?# ITA)gennaio|febbraio|marzo|aprile|maggio|giugno|luglio|agosto|settembre|ottobre|novembre|dicembre|(?# DUT)januari|februari|maart|april|mei|juni|juli|augustus|september|oktober|november|december|(?# POR)janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro|(?# CAT)Gener|Febrer|Març|Abril|Maig|Juny|Juliol|Agost|Setembre|Octubre|Novembre|Desembre) \d+
I've left in markers to label which language is included in case for any need to identify it at a later date. I then realised that this doesn't account for when a year isn't stated. I could create a second GREP style, but I'm hoping there's a simpler solution. Also, is the expression above bad-form? Is there a simpler way to express what I need?
The other spanner in the works is German, where there is a full stop after the date number. I tried to include it in the above but I got stuck. So I have this as a separate GREP style;
\d+\. ((?# GER)Januar|Februar|März|April|Mai|Juni|Juli|August|September|Oktober|November|Dezember) \d+
Is there anyway to just have one expression that covers everything (ie, all languages, German having a full stop after the date number, and whether the year is included or not)?
Copy link to clipboard
Copied
I just did the English version, but came up with this:
(?# ENG)\d+ (January|February|March|April|May|June|July|August|September|October|November|December)\s*(\d{4})*
Which works to find all the dates in the following:
1 January and 3 February and also 17 April 2016
Sometimes trying to make one super-expression makes life harder...I would keep each language separate. For the full stop, you can add that in before the \s* as \.*
Copy link to clipboard
Copied
(?# ENG)\d+\h(January|February|March|April|May|June|July|August|September|October|November|December)(\h\d{4})?
Best,
Michel, for FRIdNGE
Copy link to clipboard
Copied
Here's the german version with a bit more accuracy and much more efficiency.
(Because of: now there are only five 'main-ORs' in alphabetical order instead of eleven in mixed order)
(?:\d+\.\h((?# GER)A(pril|ugust)|([DF]e(brua|zembe)r)|J[au](li|n(i|uar))|M(ai|ärz)|(Okto|((Nov|Sept)em))ber)(\h[12]\d{3})?)
Upps: Jive (Forum software) insert an additional space in the grep after em)) -> that's why as 'code'
(?:\d+\.\h((?# GER)A(pril|ugust)|([DF]e(brua|zembe)r)|J[au](li|n(i|uar))|M(ai|ärz)|(Okto|((Nov|Sept)em))ber)(\h[12]\d{3})?)
Works to find all the dates:
1. Januar and 02. Februar and also 30. Juni 2018
Have fun
![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more