InDesign GREP reformatting of Time Ranges

New Here ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Indesign GREP newbie here. I'm receiving text of times that requires reformating. How would I format time ranges using a GREP code to omit the first "am" or "pm" from any time ranges that have "am" or "pm" twice in the same time range? Also, I'm trying to omit the ":00" from all time ranges. Is there a simple way of eliminating that in the same GREP?

 

For Example:

This is what’s provided:

• 9:15am-10:00am

• 1:00pm-3:30pm

• 11:30am-12:30pm

• 9:00am-1:00pm

 

This is what I’m aiming for:

• 9:15-10am

• 1-3:30pm

• 11:30am-12:30pm

• 9am-1pm

TOPICS
How to , Scripting

Views

104

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Adobe Community Professional , Dec 23, 2021 Dec 23, 2021
Few different GREP queries.  First consolidate the ams and pms:  Find:  (\d{2})(am)-((\d|:){4,5})(am) Change: $1-$3$5 Do the same for pm Then to remove the :00, find:  (\d)(:00) and replace with:  $1

Likes

Translate

Translate
Advocate , Dec 23, 2021 Dec 23, 2021
You achieve it with only a single query. Leave change to empty. ([ap]m)(?=-.+\1)|:00

Likes

Translate

Translate
Adobe Community Professional ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Hi David,

is every of the lines a single paragraph?

And how is the bullet done? Auto bullet list or is it typed?

 

Regards,
Uwe Laubender

( ACP )

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Few different GREP queries. 
First consolidate the ams and pms: 
Find: 

(\d{2})(am)-((\d|:){4,5})(am)

Change:

$1-$3$5

Do the same for pm

Then to remove the :00, find: 

(\d)(:00)

and replace with: 

$1

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Thank you very much! Happy holidays.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

LATEST

You achieve it with only a single query. Leave change to empty.

 

([ap]m)(?=-.+\1)|:00

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines