Skip to main content
Participant
December 23, 2021
Answered

InDesign GREP reformatting of Time Ranges

  • December 23, 2021
  • 3 replies
  • 497 views

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

This topic has been closed for replies.
Correct answer jctremblay

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

 

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

 

3 replies

jctremblay
Community Expert
jctremblayCommunity ExpertCorrect answer
Community Expert
December 24, 2021

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

 

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

 

brian_p_dts
Community Expert
Community Expert
December 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

 

Participant
December 23, 2021

Thank you very much! Happy holidays.

Community Expert
December 23, 2021

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 )