281
Basic UserBasic User
281

PostNov 30, 2025#16

I just want to say KUDOS to all who replied back with suggestions/help. It is one thing when its Mofi b/c we all know Mofi takes care of shift and answers all questions but then there are times like this one where the rest chip in and that's what makes sites like this valuable; a team effort!

Hoooo-Rahh!

6,824625
Grand MasterGrand Master
6,824625

PostNov 30, 2025#17

@Eep² The script posted by me works for s p a c e d  o u t  w o r d s with a single normal space between each character and two normal spaces between the words spaced out words. If the result is not as posted here, there are other whitespace characters than horizontal tab and normal space between the words like a no-break space.

Click in ribbon mode on ribbon tab View in first group Display on the check box item Spaces / tabs. Click in toolbar/menu mode with contemporary menus in menu View on the menu item Spaces / tabs. Click in the toolbar/menu mode with traditional menus in menu View on the menu item Show spaces/tabs. A normal space is displayed now with · and a horizontal tab with » while other whitespace characters are still displayed as defined by the used font.

Set the caret left to the whitespace character not displayed now with · or » and click in toolbar/menu mode with traditional menus on the menu item Character properties. In toolbar/menu mode with contemporary menus click in menu Edit on the menu item Character info. Click in ribbon mode on ribbon tab Edit in second group Review on the item Character info. The Character Properties window is displayed showing the decimal and hexadecimal value of the character. A no-break space has the decimal value 160 which is hexadecimal 0xa0.

There can be following three variants of whitespace sequences between two words with at least one no-break space:
  1. A normal space followed by a no-break space where it would be best to delete the no-break space (second whitespace) and keep the normal space (first whitespace).
  2. A no-break space followed by a normal space where it would be best to delete the no-break space (first whitespace) and keep the normal space (second whitespace).
  3. Two no-break spaces where it would be best to replace both no-break spaces by one normal space.
It is perhaps possible to do all the space removals / replaces with a single Perl regular expression replace all on selected text, but that is not trivial. It would be easier to use multiple replaces on the selected text if there are all three variants possible at the same time. It would be easier to use a single Perl regular expression replace all on selected text if just one of the three variants exist usually in the text to modify.

5
NewbieNewbie
5

PostNov 30, 2025#18

The spaces are normal spaces ("·") but the script does not remove triple spaces--it turns out the text I'm trying to fix has 3 spaces between words, not 2. I didn't notice that before and only after you told me about the "show spaces/tabs" option did I see it. Sorry. It seems if I just run the script 2 times over the same selection, the remaining double spaces shrink to 1 space and the other single spaces are left alone. Is there a way to loop the script 2 times?

6,824625
Grand MasterGrand Master
6,824625

PostNov 30, 2025#19

I suggest a modification of the search expression from "[\\t ](?![\\t ])" to " \\K +| " with three normal spaces between words.

Explanation of the new search expression:

Search for a single normal space and keep back (deselect) that space which is followed by one or more normal spaces or search for a single space (selected) and replace the selected space(s) by an empty string.

The new search expression matches therefore all normal spaces in a series of normal spaces with the exception of the first normal space in that series or every other normal space. The rest of the script is kept as is, just the search expression must be modified to delete the normal spaces between the characters of words and delete all normal spaces between words except the first normal space.

5
NewbieNewbie
5

PostNov 30, 2025#20

Thanks! I changed just this line [forgot to add the start/end spaces after/before quotes (") the first time]:

Code: Select all

UltraEdit.activeDocument.findReplace.replace(" \\K +| ","");

Read more posts (-10 remaining)