Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Posts
    162
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Replace hyphens between numbers with en-dashes

    In Word 2010, I would like to convert hyphens separating numbers (like dates, page ranges, etc.) to en-dashes. How would I phrase a find/replace search to do that? Thanks so much.
    Clark

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,389
    Thanks
    208
    Thanked 831 Times in 764 Posts
    Clark,

    You can accomplish this in the main document via a Regular Expression as follows:
    Using Search and Replace (Ctrl+H)
    In the Find box: ([0-9])(-)([0-9])
    In the Replace box: \1--\3 (Note: I used -- to denote the en-dash but you would enter the correct character by holding Ctrl and pressing the minus on the Number Key pad!)
    Also make sure that the Use Wild Cards option is checked and that Search: is set to ALL.

    SandRRegEx.JPG

    Also NOTE: This will not with any numbers that are displayed via Field Codes like page numbers, number of pages, figure numbers, etc.

    How it works:
    The find box:
    The parens () set up groups, in this case 3 groups (first number) (hyphen/dash) (second number)
    The [] setups a range and will match any one 1 thus [0-9] will select any single digit number
    The replace box:
    We tell it to keep the first number by using \1 {group 1}
    We tell it to replace the hyphen/dash by typing the code for the en-dash
    We tell it to keep the 2 number by using the \3 {group 3 in the Find box}

    HTH
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  3. #3
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    120
    Thanks
    3
    Thanked 20 Times in 18 Posts
    The en dash may be an available option via the Special pulldown in the Find and Replace "More>>" dialog—and if it is, will appear in the replace with box as the ^= token (and ^+ for the longer em dash).

    RetiredGeek's Ctrl-NumericPadHyphen entry method will work for the en dash (in Windows; Option-Minus on a Mac), but the result can be hard to differentiate from a hyphen in a dialog box. An alternative is to use ^0150 to enter the en dash character (and ^0151 for an em dash).

  4. #4
    2 Star Lounger
    Join Date
    Mar 2001
    Posts
    162
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Works great. Thanks!

  5. #5
    New Lounger
    Join Date
    Sep 2011
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by altdotcom View Post
    Works great. Thanks!
    Which one?
    Computer Specs:
    Windows 7 Pro 64 -Bit
    1000W Silent Fan Power Supply
    Asus Z87-Pro MotherB
    4th Gen. Intel Core i7-4770K 3.5GHz Chip
    Crucial 32GB DDR3 Memory
    Nvidia GeForce GTX 660 2GB Video
    3 1TB SATA 6.0Gb/s 64MB HHD's
    Super Multi Blu-ray Burner
    24X DL 8.5GB DVD Burner

  6. #6
    New Lounger
    Join Date
    Mar 2013
    Location
    Atlanta, Ga
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    altdotcom,
    There is an alternate way using ASCII keys. For an 'en' short dash: hold the alt key and type 0150. For a longer dash: type 0151.

  7. #7
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    120
    Thanks
    3
    Thanked 20 Times in 18 Posts
    Be sure to use the numeric keypad for the digits when you use lfh003's tip. It doesn't work if you use the numbers on the normal keyboard.

  8. #8
    New Lounger
    Join Date
    Mar 2013
    Location
    Atlanta, Ga
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Eric,
    Thanks for the follow-up. My mistake was to ASSUME everyone knew to use the numeric keypad...my bad. Luther

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •