Ask Your Question

# How to convert every hyphen/dash between numbers to en-dash? [closed]

The question says it all: how does one convert every dash between numbers to en-dash (a common publishing convention)? That is, change e.g. "27-32" to "27–32" without changing the hypen in, e.g. "bitter-sweet" to an en-dash as well?

edit retag reopen merge delete

## 2 Answers

Sort by » oldest newest most voted

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.

more

Sorry I messed up the attempt to make a corrective comment to my answer. Here the correction - and I hope not save mistake happens again.

Orignal answer:

actually there should be space between figures and a hyphen/dash/en-dash when you write a text in writer. (mathematical formulas in Calc are different!!!)

Thus when you type: "2 space hyphen space 3 space" the hyphen (short) changes to the en-dash (longer) The "space" after the "3" triggers writer to change the hyphen to the en-dash.

Corrective comment:

i need to apologize because me answer above contains an error. My statement "actually there should be space between figures and a hyphen/dash/en-dash when you write a text in writer." is wrong. Between to numbers, indicating a range from a to b there should be no space before and after the en dash.

Best to read: https://en.wikipedia.org/wiki/Dash and note there under "Em dash" the paragraph "According to most American sources (such as The Chicago Manual of Style) and some British sources (such as The Oxford Guide to Style), an em dash should always be set closed, meaning it should not be surrounded by spaces. But the practice in some parts of the English-speaking world, including the style recommended by The New York Times Manual of Style and Usage, sets it open, separating it from its surrounding words by using spaces or hair spaces (U+200A) when it is being used parenthetically. Some writers, finding the em dash unappealingly long, prefer to use an open-set en dash. This "space, en dash, space" sequence is also the predominant style in German and French typography. See En dash versus em dash below."

more

## Comments

@ROSt52 - thanks for the update. I'm sure there are variations between publishers, regions, disciplines, etc. It's good to have the extra information!

( 2012-10-29 00:15:13 +0200 )edit

@David - I am glad I could give you some hints. I personally stick with the way LibO deals with en-dash and em-dash. It takes for the hyphen, minus as en dash and the em dash as created by LibO. For me it is more important to have a clear view on the text written and follow the exceptions.

( 2012-10-29 04:32:53 +0200 )edit

Thank you David for a brilliant solution! I'm editing 18 x 50 page documents to unify the format, with thousands of references this 'trick' has saved me a lot of time. I did not know 'regular expressions', now you've whetted my appetite to master more. Thank you!

( 2012-10-30 13:17:51 +0200 )edit

@Yohane - Zikomo! ;) If quotation marks in your documents are an issue, then have a look here: http://ask.libreoffice.org/question/2612/how-do-i-convert-straight-quotes-to-typographic/

( 2012-10-31 21:52:40 +0200 )edit

## Stats

Asked: 2012-10-22 09:35:23 +0200

Seen: 3,748 times

Last updated: Oct 31 '12