Deleting space prior to em dashes.

I have a lengthy manuscript that has a lot of em dashes preceded and followed by a space. I am trying to delete these spaces. The auto correct is set to change dashes while typing. This is not my issue. I want to do something like “find and replace” to delete the spaces prior to and following the em dash. Thank you.

.

I want to do something like “find and
replace” to delete the spaces prior to
and following the em dash.

Paste in the SEARCH input line (this is SPACE EMDASH SPACE), then paste in the REPLACE input line (EMDASH only), then click FIND ALL, then click REPLACE ALL.

Advice: Use copy/cut and paste for the operation to avoid wrong characters in the SEARCH input line.

This procedure only erases leading AND following spaces of the em dash.

Spaces in general prior/following of em dash can be erased in one step by this:

Activate REGULAR EXPRESSIONS

SEARCH input line: — |— | — ↔ SPACE EMDASH SPACE|EMDASH SPACE|SPACE EMDASH

(The PIPE SYMBOL ↔ | means OR.

A more universal regex would be \s*—\s* :slight_smile: - if more precision is needed, \s may be replaced by SPACE character to only handle specific character instead of all whitespace characters, and * by ? to only handle single optional character instead of any number of leading/trailing ones. Reference: ICU documentation.

Brilliant! Worked perfectly! THANK YOU for saving me hours of work. :slight_smile: