Jump to content

Finding double spaces works poorly


Recommended Posts

I have been trying to find and replace double spaces in the text with single spaces.

I am finding that the search feature is very hit and miss. I continually find double spaces while eyeballing the text which I have to correct manually.

Is there some reason the search feature is missing so many?

I have found this in searching for other things as well. Is this feature still under development?

Thanks

Link to comment
Share on other sites

Here's one reason that might happen, @gumbo23.

Suppose you have a string with 3 spaces, such as

ABC   DEF

And suppose you do a Find for "  " (2 spaces) and replace with 1 space.

Your Find operation generates a results list, where the list contains 1 entry, "ABC   DEF" with the first 2 spaces selected.

The Replace will replace those 2 spaces with 1 space. But now you still have

ABC  DEF

with 2 spaces (the one you added, and the original one that your Find operation didn't select). So you would need to do another Find.

Or, to make it easier, you need to use Regular Expression searching. Find

 {2,}

(that's " {2,}") and replace with a single space.

Or, if you want to cover all kinds of whitespace (non-breaking spaces, tabs, narrow spaces, etc.) use "\s{2,}" as the search term.

-- Walt

Desktop:  Windows 11 Home, version 22H2 (22621.1413) 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 
Laptop:  Windows 10 Home, version 21H2 (19044.2728) 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
        Affinity Photo 1.10.6 (.1665) and 2.1.0 and 2.1.0. beta/ Affinity Designer 1.10.6 (.1665)  and 2.1.0  and 2.1.0 beta / Affinity Publisher 1.10.6 (.1665)  and 2.1.0  and 2.1.0beta
iPad Pro M1, 12.9", iPadOS 16.4.1 (a), Apple Pencil 2, Magic Keyboard

      Affinity Photo 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Designer 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Publisher 2.1.0 and 2.1.0 beta

Link to comment
Share on other sites

5 minutes ago, gumbo23 said:

Use this exactly?

I tried, but it found nothing - though I know there must be dozens more cases in the doc.

 

Yes, that exactly. It will find any combination of 2 or more whitespace characters.

But, perhaps you don't have the Regular Expression option enabled? That seems to be the default for me, but check your Find options using the gear/cog icon to the right of the Find box.

-- Walt

Desktop:  Windows 11 Home, version 22H2 (22621.1413) 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 
Laptop:  Windows 10 Home, version 21H2 (19044.2728) 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
        Affinity Photo 1.10.6 (.1665) and 2.1.0 and 2.1.0. beta/ Affinity Designer 1.10.6 (.1665)  and 2.1.0  and 2.1.0 beta / Affinity Publisher 1.10.6 (.1665)  and 2.1.0  and 2.1.0beta
iPad Pro M1, 12.9", iPadOS 16.4.1 (a), Apple Pencil 2, Magic Keyboard

      Affinity Photo 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Designer 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Publisher 2.1.0 and 2.1.0 beta

Link to comment
Share on other sites

1 minute ago, walt.farrell said:

Yes, that exactly. It will find any combination of 2 or more whitespace characters.

But, perhaps you don't have the Regular Expression option enabled? That seems to be the default for me, but check your Find options using the gear/cog icon to the right of the Find box.

I tried it both ways, with no joy.

I have the latest version installed. 

Any other thoughts?

Link to comment
Share on other sites

11 minutes ago, gumbo23 said:

Any other thoughts?

Please show a screenshot of the Find panel, and the Find options.

Also, if you can provide a sample .afpub file that would be helpful.

 

-- Walt

Desktop:  Windows 11 Home, version 22H2 (22621.1413) 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 
Laptop:  Windows 10 Home, version 21H2 (19044.2728) 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
        Affinity Photo 1.10.6 (.1665) and 2.1.0 and 2.1.0. beta/ Affinity Designer 1.10.6 (.1665)  and 2.1.0  and 2.1.0 beta / Affinity Publisher 1.10.6 (.1665)  and 2.1.0  and 2.1.0beta
iPad Pro M1, 12.9", iPadOS 16.4.1 (a), Apple Pencil 2, Magic Keyboard

      Affinity Photo 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Designer 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Publisher 2.1.0 and 2.1.0 beta

Link to comment
Share on other sites

31 minutes ago, Petar Petrenko said:

can you put a link here, where I can find some help about RegEx used in Publisher?

This is the documentation that is specific to the library that Publisher uses, I think: https://www.boost.org/doc/libs/1_73_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

There are lots of other documentation sites for regular expressions, of course, including this one for the Python implementation, which I also use: https://docs.python.org/3/library/re.html?highlight=re#module-re

 

-- Walt

Desktop:  Windows 11 Home, version 22H2 (22621.1413) 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 
Laptop:  Windows 10 Home, version 21H2 (19044.2728) 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
        Affinity Photo 1.10.6 (.1665) and 2.1.0 and 2.1.0. beta/ Affinity Designer 1.10.6 (.1665)  and 2.1.0  and 2.1.0 beta / Affinity Publisher 1.10.6 (.1665)  and 2.1.0  and 2.1.0beta
iPad Pro M1, 12.9", iPadOS 16.4.1 (a), Apple Pencil 2, Magic Keyboard

      Affinity Photo 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Designer 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Publisher 2.1.0 and 2.1.0 beta

Link to comment
Share on other sites

On 6/23/2020 at 9:40 PM, Petar Petrenko said:

a link here, where I can find some help about RegEx used in Publisher?

You also might like  http://regexlib.com/Search.aspx  which doesn't list syntax only but also includes many samples of complex expressions, shows comparisons of results which are affected towards those which aren't (Matches / Non-Matches) and offers a test area. – Though not all of them may fit to the specific RegEx used in APub it can be helpful.

macOS 10.14.6 | MacBookPro Retina 15" | Eizo 27" | Affinity V1 only

Link to comment
Share on other sites

48 minutes ago, Petar Petrenko said:

I found this book on the internet:

https://www.princeton.edu/~mlovett/reference/Regular-Expressions

is the sintax used in it valid for use in Publisher?

Probably valid (as it's for Perl Compatible Regular Expressions), but as it's from 2007 it's perhaps incomplete and missing some aspects of the Boost RegEx engine that support functions developed in the last 13 years. The differences are likely small, but potentially significant. So if you try something in it and it doesn't work quite as you expect, I would compare it with the Boost documentation. Also, there may be aspects of RegEx syntax/function from those 13 years that may make some functions easier, or possible, that weren't back in 2007.

It's probably a good start if you're not already a RegEx expert :)

-- Walt

Desktop:  Windows 11 Home, version 22H2 (22621.1413) 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 
Laptop:  Windows 10 Home, version 21H2 (19044.2728) 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
        Affinity Photo 1.10.6 (.1665) and 2.1.0 and 2.1.0. beta/ Affinity Designer 1.10.6 (.1665)  and 2.1.0  and 2.1.0 beta / Affinity Publisher 1.10.6 (.1665)  and 2.1.0  and 2.1.0beta
iPad Pro M1, 12.9", iPadOS 16.4.1 (a), Apple Pencil 2, Magic Keyboard

      Affinity Photo 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Designer 1.10.7 and 2.1.0 and 2.1.0 beta/ Affinity Publisher 2.1.0 and 2.1.0 beta

Link to comment
Share on other sites

macOS 10.14.6 | MacBookPro Retina 15" | Eizo 27" | Affinity V1 only

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

Please note there is currently a delay in replying to some post. See pinned thread in the Questions forum. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.