En dash between numbers

G

greggsewell

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

I want to replace hyphens between numbers with en dashes.

I can find them all using wildcards with [0-9]-[0-9].

What do I enter in the Replace field to change the hyphen to an en dash?

Thanks very much for your help.
 
C

CyberTaz

Hi Gregg -

I'm sure there is a more elegant technique, but until someone else posts it
- or perhaps even an Apple Script - perhaps my awkward way will help:

Type the EnDash (Command +NumPad -) in a document, Shift+LeftArrow to select
it, Copy or Cut, then go to the Replace field in the dialog window & use
Command+V to paste... It won't *look* like an EnDash in the dialog but
that's what will be inserted in the doc for any replacements.

HTH |:>)
Bob Jones
[MVP] Office:Mac
 
G

greggsewell

Thanks, Bob, but your suggestion doesn't work.

If the only thing in the Replace field is the en dash, then the entire number/hyphen/number string (which is selected by the Find) is replaced, leaving only an en dash.

Here's an example with the underscore character _ standing in for an en dash.

I have:

1-2
11-22
111-222
1111-2222

I want:

1_2
11_22
111_222
1111_2222

Using your technique, I get:

_
1_2
11_22
111_222

Again, I want to find all hyphens between numbers and replace only the hyphen with an en dash.

This string also finds what I'm looking for:

^#-^#

But I don't know enough about regular expressions to know how to "say" "Deselect the string you found and replace only the hyphen with the en dash."

I searched and studied several tutorials on regular expressions, including what was available via the Word MVP site. Lots of help with creating expressions, but not much at all about what goes in the Replace field.

Again, I appreciate your help.

I feel that I have to take the time to pursue this because I'm just starting on a document that's 1,000-plus pages and chock full of dates, page ranges, and about a half-dozen varieties of number/hyphen/number combinations.
 
E

Elliott Roper

But I don't know enough about regular expressions to know how to "say"
"Deselect the string you found and replace only the hyphen with the en dash."

I searched and studied several tutorials on regular expressions, including
what was available via the Word MVP site. Lots of help with creating
expressions, but not much at all about what goes in the Replace field.

Again, I appreciate your help.

You are nearly there. As long as 2008 works the same as 2004 (which is
where I tested it.) You will find the trick in the second note in the
help topic "advanced search methods"
With use wildcards checked in the find/replace expanded dialog box:
Find
([0-9])-([0-9])
replace
\1Ñ\2

It's that easy.
In case the help in 2008 is even worse than 2004's Here's what it says:-
"You can use the \n wildcard to search for an expression and then
replace it with the rearranged expression. For example, type (Newton)
(Christie) in the Find what box and \2 \1 in the Replace with box. Word
will find "Newton Christie" and replace it with "Christie Newton" "

Or in my own words,:- Wrap each search sub-expression in parentheses.
It will then be held for replacement. The nth wrapped sub-expression in
the search is retrieved with \n

Note also the Mac-wide keystroke for an en dash is alt-hyphen. It even
works in the replace box in Word.

Also note (with sadness) that your ^# expression does not work with
wildcards enabled in Word's Ÿber-lame regexp implementation. You will
have to use the more prolix [0-9] form.
 
G

greggsewell

Bob,

My heart is happy.

Thank you very, very much, for "the answer" as well as the explanation.

I guess I got frustrated and stopped reading just before I would have discovered the solution (unlike Bogart at the end of The African Queen, who didn't give up).

Anyway, I'm very grateful.

I know so little about Word, but would like to give back in some way.

Suggestions?
 
C

CyberTaz

Actually, the answer came from Elliott Roper - it's rumored he does such
things in his sleep :) so he popped it in before I had a chance to figure
it out. All props go to him.

As far as "giving back", that's what the group is all about. Slip in
whenever you have an opportunity & provide any knowledgeable replies you can
to the posts you might be able to answer. Just be careful not to get
addicted the way the rest of us have :)

Regards |:>)
Bob Jones
[MVP] Office:Mac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top