• Replace hyphens between numbers with en-dashes

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Replace hyphens between numbers with en-dashes

    Author
    Topic
    #495521

    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

    Viewing 3 reply threads
    Author
    Replies
    • #1459358

      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.

      37374-SandRRegEx

      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 :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1459407

        Works great. Thanks!

        • #1459723

          Works great. Thanks!

          Which one?

        • #1459904

          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.

    • #1459389

      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).

    • #1460036

      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.

    • #1460037

      Eric,
      Thanks for the follow-up. My mistake was to ASSUME everyone knew to use the numeric keypad…my bad. Luther

    Viewing 3 reply threads
    Reply To: Replace hyphens between numbers with en-dashes

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: