Skip to main content
Community Expert
February 12, 2026
Question

Replace regular spaces before units with non-breaking spaces

  • February 12, 2026
  • 1 reply
  • 0 views

Hi,

For all who have similar needs and who might find this helpful. I know that you could also combine this in an ExtendScript script, but for now this is just a short hack.

Usually I enter non-breaking spaces before units. However, sometimes there are regular spaces.

And when I get translations back, the translators often ignore this as well. Therefore here a regular expression to find numbers with units with no or regular spaces. Of course you can adapt this to your needs.

And do not forget to select Regular Expressions in the Find/Replace dialog.

I closed all units with \b, although this is definitely not needed for all.

Find:

(\d) *(%\b|(°C)\b|(µm)\b|A\b|(Ah)\b|(bps)\b|(Byte)\b|(Bytes)\b|(cm)\b|(dB)\b|g\b|(GB)\b|(hours)\b|(Hz)\b|(Jahre)\b|(kA)\b|(kB)\b|(kbps)\b|(kg)\b|(kHz)\b|(km)\b|(kOhm)\b|(kV)\b|(kW)\b|(kΩ)\b|m\b|(mA)\b|(mAh)\b|(MB)\b|(MHz)\b|(Minuten)\b|(minutes)\b|(mm)\b|(mT)\b|(mTesla)\b|(mV)\b|(mW)\b|(MW)\b|(Ohm)\b|(Pixel)\b|(pixel)\b|s\b|(sec.)\b|(Sek.)\b|(Stunden)\b|V\b|W\b|(years)\b|Ω\b)

Replace:

$1\ $2

And I have also RS-485 or RS-232, where I want non-breaking hyphens. I replaced with \+ which works for Replace, but not for Find. For Find you have to use \x15 from the Windows character set (in the online help in the appendix).

Find:

(RS)[ -]?(\d)

Replace:

$1\+$2

And I have RJ45 or RJ12, where I do not want any spaces or hyphens.

Find:

(RJ)( |-|\x15)?(\d)

Replace:

$1$3

Best regards, Winfried

    1 reply

    Bob_Niland
    Community Expert
    Community Expert
    February 12, 2026

    The damage that translators can do is impressive, and I’ll bet they are aided by clueless AIs these days.

    Another approach on non-breaking spaces and hyphens is Variables. A translator might be less likely to blindly over-write a variable.

    Name: U00A0 NO-BREAK SPACE
    Def: \u00a0
    Name: U2011 NON-BREAKING HYPHEN
    Def: \u2011

    While the FM native Ctrl-spacebar and Esc--h specials get encoded as specific FM data objects,
    in MIF as ‹Char HardSpace› and ‹Char HardHyphen›
    they go out to HTML as standard U+0020 and U+002D space and hyphen. It appears that they are only honored during authoring.

    As Variables, interestingly, they go out as:
    ‹span data-keyref="U00A0 NO-BREAK SPACE"›nbsp;‹/span›
    ‹span data-keyref="U2011 NON-BREAKING HYPHEN"›‑‹/span›
    And the “‑” is a real U+2011

    What I haven’t done yet is to see if FM honors the non-break semantic during authoring.

     

    Notes:

    The ‹, › and & here are non-ASCII codepoints, to prevent re-interpretation as markup by the new site engine (which I haven’t tested for this problem that the old one had).

    It would necessary to ensure that your fonts populate U+2011, as FM does not do fallback.

    I haven’t tested various browsers to see if they honor the NB property of U+2011.