Using Search/Power Search

Everything related to our flagship word processor.
Post Reply
markospc
Posts: 1
Joined: 2015-09-02 02:53:59

Using Search/Power Search

Post by markospc »

Hi everyone

I am finishing my master's thesis these days.

Today I found out that in the midst of the 200k plus characters the whole document has there apparently are a few cases where I simply forgot to put space between two characters.

While I know that I can find double spaces and replace them easily, how would I go about in finding instances of the like: "any letter"+"any pucntuation mark"+"any letter" with no space in between them? I thought these cases would be detected using the spell check. However, this seems not to be the case (at least in the footnotes).

Is there anything I can do?

Thanks in advance for every answer and remark!

Sincerely,
Markos
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Using Search/Power Search

Post by adryan »

G’day, Markos et al

If I understand you correctly, the following should do what you want.

In the PowerFind Pro Find/Replace dialog box, insert the indicated expressions:–

(1) Find what: (.)(\.)([^ ])
(2) Replace with: \1\2 \3

Note that there is a space character after the caret in the Find expression and another space character after the “2” in the Replace expression.

Hope this helps.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Using Search/Power Search

Post by adryan »

G’day, Markos et al

The expression in the Find field should be (.)(\p{P})([^ ])

This should pick up all punctuation marks, not just periods (full stops) as in my previously posted expression. Sorry about that.

Once again, there is a space character after the caret.

And the usual caveat: Always have a duplicate file as a backup whenever you use a macro or apply any global replace operation, in case of mishap.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
Þorvarður
Posts: 410
Joined: 2012-12-19 05:02:52

Re: Using Search/Power Search

Post by Þorvarður »

Hi Markos,

If your thesis is in English, then Adrian's search expression will also find apostrophes and hyphens, which I think you might not want, because this would add an extra space to words where there should be no space. Example: "I don't know" would become "I don' t know" (with a space after ') and "I want a blow-by-blow account of the meeting" would become "I want a blow- by- blow account of the meeting" (with spaces after the hyphens).

So, if you want to find punctuation marks which are followed by a letter, then that means
1. You must exclude apostrophes and hyphens
2. The punctuation mark should not be followed by a space

I first tried to use "Any Punctuation" in conjunction with eliminating apostrophes in the Find Box, but that did not give me the desired result. So I think it would be best to
1. tell Nisus exactly what punctuation characters you want to find. They are only a handful, and "CharactersInSet" can do that.
2. Once Nisus knows what characters it should look for, you just have to add that these characters are not to be followed by a space. (I also excluded Return in order to prevent an extra, superfluous space being added to the last punctuation character in your document.)
1.png
1.png (23.45 KiB) Viewed 5946 times
The characters in the set are .,!?:;

Replace with
2.png
2.png (10.47 KiB) Viewed 5978 times
The macro creates a new document with all changes in context, so you can easily check whether anything went wrong.
markospc wrote:I am finishing my master's thesis these days.
Congratulations! — What is your topic?

Þorvarður
Attachments
Punctuation not followed by Space; Find and Replace.nwm.zip
(2.16 KiB) Downloaded 313 times
Last edited by Þorvarður on 2015-09-04 01:24:28, edited 1 time in total.
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Using Search/Power Search

Post by adryan »

G’day, Þorvarður et al

Yes, I merely used the “Any Punctuation” option in PowerFind Pro’s Wild Card Menu. Specifically designating a set of elements which are to be included or excluded from a Find expression, as Þorvarður has suggested, allows greater flexibility, especially if punctuation marks (or any other characters, for that matter) from non-English languages are involved.

In the present case, one needs to give very careful consideration to exactly what one's Find expression will actually find. You don’t want to see all your decimal points (including any that may designate Figure or Table identifiers) having an unwanted space inserted after them. The same would apply to commas if you were using them in your currency Preferences. Any mathematical expressions would be especially vulnerable. You may need to include "Any Digit" in your set of “NotFollowedBy” characters, being aware that some mathematical expressions might be altered when you had rather they were not.

You might consider adding parentheses, brackets and/or braces to your Find expression, but you may find (in)advertent errors creeping in as a result. In addition to the one just flagged in the preceding sentence, don’t forget list identifiers such as “3(iv)(a)”.

A lot depends on the content of your manuscript. A single Find/Replace expression or macro is unlikely to serve everyone’s purposes. The best you can do is try to automate things as much as possible, but to be prepared to do careful proofreading afterwards.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
Þorvarður
Posts: 410
Joined: 2012-12-19 05:02:52

Re: Using Search/Power Search

Post by Þorvarður »

adryan wrote:You don’t want to see all your decimal points (including any that may designate Figure or Table identifiers) having an unwanted space inserted after them. The same would apply to commas if you were using them in your currency Preferences. Any mathematical expressions would be especially vulnerable.
Good point, Adrian. I hadn't thought of that. :-)

I have now added "Any Digit" in the set of “NotFollowedBy” characters.
Post Reply