Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It turns out there is a trick to the use LibreOffice's regular expressions that took a bit of head-scratching. For changing hyphen/dash to en-dash between numbers only, this is what to do:

  1. CTRL-H to open search/replace dialog, then click the "More Options" button (if not already displayed) and enable the "[x] Regular expressions" option.
  2. In the "Search for" box, paste in: ([0-9])-([0-9])
  3. In the "Replace with box, paste in: $1–$2
  4. Click "Replace All" button. Done!

That ought to do it. It works for me, at any rate! Hope this is a help for others.

click to hide/show revision 2
added a bit of code commentary

It turns out there is a trick to the use LibreOffice's regular expressions that took a bit of head-scratching. For changing hyphen/dash to en-dash between numbers only, this is what to do:

  1. CTRL-H to open search/replace dialog, then click the "More Options" button (if not already displayed) and enable the "[x] Regular expressions" option.
  2. In the "Search for" box, paste in: ([0-9])-([0-9])
  3. In the "Replace with box, paste in: $1–$2
  4. Click "Replace All" button. Done!

Commentary: the "search" looks for any dash that is preceded and followed by a number. The "replace" value changes only the dash to an en-dash, while $1 and $2 represent the values found in the search for the first and second terms, and retains them unchanged.

That ought to do it. It works for me, at any rate! Hope this is a help for others.