Jump to content

Find Replace not working properly with regular expression in case of “Replace all”


Recommended Posts

Below is my response to the questionary and the description of the bug. My answers are in green

  1. Are you using the latest release version? Yes
  2. Can you reproduce it? I don’t understand the question.
  3. Does it happen for a new document? Yes If not can you upload a document that shows the problem?
  4. If you cannot provide a sample document then please give an accurate description of the problem for example it should include most of the following:
  •    What is your operating system and version (Windows 11, OSX Ventura, iOS 16 etc)? Windows 11. This bug was not present on the same machine with the same operating system in the version 1 of Publisher.
  •    Is hardware acceleration (in Preferences > Performance) ON or OFF ? (and have you tried the other setting?) I have tried both setting but nothing changes.
  •    What happened for you (and what you expected to happen)  The “replace all” function deletes all but one letter of each given word which corresponds to my search criteria. More information below. The problem doesn’t affect the normal “replace” function, in other words, I don’t experience the same problem if I replace glyph by glyph (but I have to replace thousands of glyphs!).
  •    Provide a recipe for creating the problem (step-by-step what you did).  I searched all glyph with a given character style by using the simple regular expression “.”. I wanted to replace each glyph with another style by digiting “$0” in the replace window. When replacing all, all my words were cut off.
  •    Screenshots (very handy) or a screen capture/video. Please see below.
  •    Any unusual hardware (like tablets or external monitors or drives that may affect things) or relevant other applications like font managers or display managers. I can’t figure out no unusual hardware and no application that could affect this problem.
  •    Did this same thing used to work and if so have you changed anything recently? (software or hardware) Nothing changed as far as I know.

This is before applying “replace all”. The circled words correspond to the words found by my search criteria.

image.png.1e830290625d414b27cccbb27900256b.png

 

This is what happens when I click on “replace all” (“sostituisci tutto” in Italian)

image.png.57281953e9fd608bb908ce3c4fe654bc.png

As you can see, the first glyph of the first word selected by my search criteria survive in the first word. The second glyph is shown in the second word (but the second word is deleted!) and similarly the third glyph is shown in the third word which is disappeared.

I have used this system for years in Affinity Publisher, since the version 1.8 or 1.9. It has always worked properly. Only here, in the version 2, the bug shows up (both in the 2.0.0 and in the 2.0.3 versions).

Link to comment
Share on other sites

What are the formats Variabile (in the Find options) and Pali Corsivo (in the Replace options)?

Can you give us a sample .afpub file to play with?

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
    Laptop 2: Windows 11 Pro 24H2,  16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU
iPad:  iPad Pro M1, 12.9": iPadOS 18.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1

Link to comment
Share on other sites

Hi Walt,

 

Thank you for your reply. Below is the sample file.

The two formats, which I chose, seem to be irrelevant as I tried with other style formats and even with normal local format without choosing a style format. The result are not affected by this format change. The bug seems to be in the “Replace all” function, not in the formatting attribute that you choose.

All information following is more or less for the benefit of others who could have interest in cleaning formatting without missing a lot of time.

 “Variabile” represents a generic italic style which I inherited from a LibreOffice document. “Pāli corsivo” is an italic style format with the spell checker and hyphenation set on the language Pāli. The reason for which I need to do such “Find: .” “Replace: $0” is done to tell Publisher to transform all the words in “Variabile” in “Pāli corsivo”. People can do something similar in order to transform local to global formatting. E.g., if one wants to transform all italics inherited from a .docx which are not set in a style format but just in local formatting, with a similar procedure, it is possible to do the same “Find: .” “Replace: $0” by defining a local format italic in find and a style format emphasis in replace. In this way, one can at once transform all local italics in style italics so that you can delete the local formatting with the T button without missing the italics which now are set by style. So one can polish the formatting of the book without having to set italics manually. This works only if the bug which we are talking about is fixed. I have used this procedure for many books in Publisher 1 and this has always worked. Only with Publisher 2, I noticed the bug.

I requisiti dell'illuminazione - Copia.afpub

Link to comment
Share on other sites

I don't have the fonts you use so that may be why I am not seeing any Bold Italic words like 

1881061504_ScreenShot2023-01-03at11_32_53AM.png.267557f763029fe756a9320252cd82d5.png

On 1/1/2023 at 2:52 PM, Antonio Costanzo said:

  I searched all glyph with a given character style by using the simple regular expression “.”. I wanted to replace each glyph with another style by digiting “$0” in the replace window.

I left out the dot "." in the find and the $0 in the replace and just used the "given character style" in the Find and set the replacement style. All the words were found and replaced.

Also for what it is worth there are a hell of a lot of overrides in the words I selected to look at. Over a dozen tab-stop locations for one word and a 6pt Space after override.

With proper fonts I could maybe help out more.

I also had luck with searching for the given character style and (.+) and in the replace \1 with a different formatting suggestion. Just the way I learned regex.

Mac Pro (Late 2013) Mac OS 12.7.6 
Affinity Designer 2.5.5 | Affinity Photo 2.5.5 | Affinity Publisher 2.5.5 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

Thank you Bruce,

 

Your suggestion has worked. This is very good. Thank you too for the help offer. I noticed the bug (which is probably not a bug now) for two or more weeks ago. In the meantime, I have worked hardly in this book, so I have almost finished polishing it. The sample which I send was just an old and unrefined version. Now the question is: has Serif changed something in the regex syntax?

Regarding the colour, I noticed that you can use the colour pick instrument to find out the RGB combination. So you can set the RGB numbers in the format in order to find all words with that colour. I talk about RGB because I noticed that if you use the same procedure with the CMYK, this will not work. My books are normally in CMYK, so in order to find a given colour, I have to change momentarily the profile of the book, setting it to RGB. After I have made the required editing, I revert to CMYK.

Link to comment
Share on other sites

12 minutes ago, Antonio Costanzo said:

Regarding the colour, I noticed that you can use the colour pick instrument to find out the RGB combination. So you can set the RGB numbers in the format in order to find all words with that colour. I talk about RGB because I noticed that if you use the same procedure with the CMYK, this will not work. My books are normally in CMYK, so in order to find a given colour, I have to change momentarily the profile of the book, setting it to RGB. After I have made the required editing, I revert to CMYK.

Don't change the Book's profile, just change the colour format for the readout.

This should help.

108701520_ScreenShot2023-01-03at12_32_54PM.png.a454ae36a93d709d08844d41e30475f3.png

Although I have to say that if you are going to be using colours for the text (or anything else actually) then you should really make a Document Colour Swatches Palette for the document and you can make them all Global colours and name them appropriately. Then you can search for the applied colours.

Pale Orange Header

Bright Green Header

Black Text

etc.

Mac Pro (Late 2013) Mac OS 12.7.6 
Affinity Designer 2.5.5 | Affinity Photo 2.5.5 | Affinity Publisher 2.5.5 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

I think I understand better why I had problem in find out the colour. My document was in CMYK, but the coloured text which I copy pasted from LibreOffice was defined in RGB. So, I had to change the profile of the Affinity document just in order to find something defined in RGB. Here is the screenshot:

image.thumb.png.e1b4a12f948c3e3d74317ac5e86d5adf.png

Or maybe is possible to find an RGB colour even though your document has CMYK profile, I don’t know.

Thank you for the suggestion regarding the colour swatch. If I have to publish some book in colours in future, this could help but at the moment, I don’t need colours. The brown colour I had were inherited from the source file. It was applied in the headings, so that I had to find that coloured text in order to replace the it with the appropriate heading (not coloured) text style.

Link to comment
Share on other sites

16 hours ago, Antonio Costanzo said:

but at the moment, I don’t need colours. The brown colour I had were inherited from the source file. It was applied in the headings, so that I had to find that coloured text in order to replace the it with the appropriate heading (not coloured) text style.

If all you need to do is change the colour of all the text to Black then all you need to do is select all the text using the text caret and the keyboard shortcut Command + A on Mac or Control + A in Windows  and change it to black.

Mac Pro (Late 2013) Mac OS 12.7.6 
Affinity Designer 2.5.5 | Affinity Photo 2.5.5 | Affinity Publisher 2.5.5 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

22 minutes ago, Old Bruce said:

If all you need to do is change the colour of all the text to Black then all you need to do is select all the text using the text caret and the keyboard shortcut Command + A on Mac or Control + A in Windows  and change it to black.

Thank you for the advice, but this was not my case. I needed to select that specific colour because that colour was used in such headings. By selecting that colour, I managed to select the headings who contained that colour, and in this way I was able to apply the correct heading style at the right points in the text.

Link to comment
Share on other sites

  • 5 months later...

There is an extremly usefull InDesign group on Facebook named "Treasures of GREP" with real experts Dhafir Photo and Jean-Claude Trembley. You can place your problem there and get the solution which you can use it in Publisher, too (maybe with some small modifications).

I would really appreciate if we can organize such a group at Affinity forum.

https://www.facebook.com/groups/TreasuresofGrep

Also, you can find usefull this book:

https://www.amazon.com/GREP-InDesign-InDesignSecrets-Peter-Kahrel/dp/0982508387

All the latest releases of Designer, Photo and Publisher (retail and beta) on MacOS and Windows.
15” Dell Inspiron 7559 i7 Windows 10 x64 Pro Intel Core i7-6700HQ (3.50 GHz, 6M) 16 GB Dual Channel DDR3L 1600 MHz (8GBx2) NVIDIA GeForce GTX 960M 4 GB GDDR5 500 GB SSD + 1 TB HDD UHD (3840 x 2160) Truelife LED - Backlit Touch Display
32” LG 32UN650-W display 3840 x 2160 UHD, IPS, HDR10 Color Gamut: DCI-P3 95%, Color Calibrated 2 x HDMI, 1 x DisplayPort
13.3” MacBook Pro (2017) Ventura 13.6 Intel Core i7 (3.50 GHz Dual Core) 16 GB 2133 MHz LPDDR3 Intel Iris Plus Graphics 650 1536 MB 500 GB SSD Retina Display (3360 x 2100)

Link to comment
Share on other sites

3 hours ago, Petar Petrenko said:

 I would really appreciate if we can organize such a group at Affinity forum.

We have knowledgeable reg-ex users here in the forums, and questions are generally answered when they are asked here.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
    Laptop 2: Windows 11 Pro 24H2,  16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU
iPad:  iPad Pro M1, 12.9": iPadOS 18.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1

Link to comment
Share on other sites

Well... something like Resources or Tutorials -- inside Learn and Share. To be easily noticeable.

All the latest releases of Designer, Photo and Publisher (retail and beta) on MacOS and Windows.
15” Dell Inspiron 7559 i7 Windows 10 x64 Pro Intel Core i7-6700HQ (3.50 GHz, 6M) 16 GB Dual Channel DDR3L 1600 MHz (8GBx2) NVIDIA GeForce GTX 960M 4 GB GDDR5 500 GB SSD + 1 TB HDD UHD (3840 x 2160) Truelife LED - Backlit Touch Display
32” LG 32UN650-W display 3840 x 2160 UHD, IPS, HDR10 Color Gamut: DCI-P3 95%, Color Calibrated 2 x HDMI, 1 x DisplayPort
13.3” MacBook Pro (2017) Ventura 13.6 Intel Core i7 (3.50 GHz Dual Core) 16 GB 2133 MHz LPDDR3 Intel Iris Plus Graphics 650 1536 MB 500 GB SSD Retina Display (3360 x 2100)

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...
×
×
  • Create New...

Important Information

Terms of Use | 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.