Replace hyphen with en-dash only after 4-digit years

In Composer, Lyricist, and Conductor fields, I format all names as, e.g.:
Joe Jones (German 1901-1990)
and sometimes have more than one separated by & or by \ or by | [don't ask--my point there is only that it may need to perform more than one replacement per field

I want to replace all THOSE hyphens (but NO OTHERS) with an en-dash (Alt-0150).

I'm new to the Replace action and to the Replace With Regular Expression action.

I'm willing to have the search part simply look for 4 digits followed by a hyphen and replace that with the same 4 digits followed by "–" (Alt-0150). That would isolate the only hyphens I want to replace.

What's my best method? [I'm also new to this Forum and I did spend an hour or more in the help system and on this Forum before posting]


Try an action of the type "Replace with regular expression"
Search string: (\d{4})-
Replace string: $1–

Thanks! Works great! What resource should I have gone to first to get this fairly simple solution?

Perhaps the help?

Very funny! Trust me, I was there for a long time and tried many unsuccessful trial-and-errors before I posted. EXAMPLES would be VERY helpful to that Help section!

The examples can be found here in the forum, e.g. here:

I found this thread with the search words "digit year".

1 Like