Skip to main content
Inspiring
July 1, 2023
Answered

Help with easy GREP for find/change number ranges

  • July 1, 2023
  • 1 reply
  • 563 views

Looking for an easy way to change a hyphen between dates to a long dash. e.g. 1- to 1–, etc from 0-1.

But I don't want to change hyphens that appear between numbers in URLs, or between number and word (e.g. 21-year-old) Just dates, like 2001-2008 --> 2001–2008 and also between page ranges (

The Journal of Economic History, 43, no.1 (1983): 89-100. --> 

The Journal of Economic History, 43, no.1 (1983): 89–100.

This topic has been closed for replies.
Correct answer FRIdNGE

… Excluding first Urls,

 

Find: \d\K-(?=\d)

Replace by: 

 

(^/)  The Jedi

1 reply

Community Expert
July 1, 2023

In the Find/Change Dialogs, Grep tab you can use the following

Find What :- (\d{4}) - (\d{4})

Change To :- $1 – $2

-Manan

-Manan
FRIdNGE
FRIdNGECorrect answer
July 1, 2023

… Excluding first Urls,

 

Find: \d\K-(?=\d)

Replace by: 

 

(^/)  The Jedi

Inspiring
July 1, 2023
Thanks, that works great. I need to learn GREP. Can you recommend any good tutorials/websites?