Ask Your Question
0

Deleting space prior to em dashes.

asked 2019-08-10 01:48:52 +0200

cgm95 gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-08-10 08:43:43 +0200

Grantler gravatar image

updated 2019-08-10 08:53:04 +0200

.

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.

edit flag offensive delete link more

Comments

A more universal regex would be \s*—\s* :-) - 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.

Mike Kaganski gravatar imageMike Kaganski ( 2019-08-10 09:20:36 +0200 )edit

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

cgm95 gravatar imagecgm95 ( 2019-08-10 16:59:48 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-08-10 01:48:52 +0200

Seen: 19 times

Last updated: Aug 10