Pyanepsion Posted July 2, 2021 Posted July 2, 2021 Hello everyone, I would like to replace all standard spaces between two figures (\d) with thin spaces using Regex. Examples: 100 000, 54 000, etc. How to proceed? Thank you for your explanations. Quote 6 cœurs, 12 processus - Windows 11 pro - 4K - DirectX 12 - Suite universelle Affinity (Affinity Publisher, Affinity Designer, Affinity Photo). ███ Mais je vous le demande, peut-on imaginer une police sans sérifs ?
walt.farrell Posted July 2, 2021 Posted July 2, 2021 In the Find panel, first make sure you have Regular Expression mode enabled in the format options for the Find field. Then, copy a Thin Space from somewhere. For example, you can insert one in your document by using Text > Insert > Spaces and Tabs > Thin Space and then copy it. Or you can type U+2009 and then Alt+U, and then copy the character. (This step is needed because the "Special Characters" part of the Replace dialog doesn't include Thin Space as one of the options.) In the Find field, type (\d) (\d) with a normal space in the middle. In the Replace field type \1 then Paste the Thin Space from step 2, then type \2 Click the Find button, then the Replace button. Pyanepsion 1 Quote -- 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.5, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.5
Old Bruce Posted July 2, 2021 Posted July 2, 2021 Find (\d) (\d) That is a regular space in there Replace \1thinspace\2 You have to copy paste the thin space from somewhere into the replace field. Pyanepsion 1 Quote Mac Pro (Late 2013) Mac OS 12.7.6 Affinity Designer 2.6.0 | Affinity Photo 2.6.0 | Affinity Publisher 2.6.0 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that.
Pyanepsion Posted July 2, 2021 Author Posted July 2, 2021 Thank you, Walt Farrell and Old Bruce. walt.farrell 1 Quote 6 cœurs, 12 processus - Windows 11 pro - 4K - DirectX 12 - Suite universelle Affinity (Affinity Publisher, Affinity Designer, Affinity Photo). ███ Mais je vous le demande, peut-on imaginer une police sans sérifs ?
David in Яuislip Posted July 2, 2021 Posted July 2, 2021 I didn't need regex, it worked set to normal Top text is original Centre text I did manually - I got the thin space from the Glyph Browser Bottom text done by Search/Replace Two caveats: the reduced space width sort of confuses the layout be careful with Replace All, it isn't constrained to the selected Text frame but jumps to the top one and changes that too. Quote Microsoft Windows 11 Home, Intel i7-1360P 2.20 GHz, 32 GB RAM, 1TB SSD, Intel Iris Xe Affinity Photo - 24/05/20, Affinity Publisher - 06/12/20, KTM Superduke - 27/09/10
walt.farrell Posted July 2, 2021 Posted July 2, 2021 2 minutes ago, David in Яuislip said: I didn't need regex, it worked set to normal But @Pyanepsion did not want to replace all the spaces with thin spaces; only the ones between two digits. True, that doesn't require regex either, but you'll be hitting Find a lot to move past the ones you don't want to change if you use a normal operation rather than regex. Quote -- 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.5, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.5
David in Яuislip Posted July 2, 2021 Posted July 2, 2021 @walt.farrellYou're quite correct, forget my drivel walt.farrell 1 Quote Microsoft Windows 11 Home, Intel i7-1360P 2.20 GHz, 32 GB RAM, 1TB SSD, Intel Iris Xe Affinity Photo - 24/05/20, Affinity Publisher - 06/12/20, KTM Superduke - 27/09/10
Old Bruce Posted July 2, 2021 Posted July 2, 2021 24 minutes ago, David in Яuislip said: be careful with Replace All, it isn't constrained to the selected Text frame Sadly it is not constrained by the text flow either. It is set to search and replace in ALL of the text in the document. walt.farrell 1 Quote Mac Pro (Late 2013) Mac OS 12.7.6 Affinity Designer 2.6.0 | Affinity Photo 2.6.0 | Affinity Publisher 2.6.0 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that.
Pyanepsion Posted July 3, 2021 Author Posted July 3, 2021 9 hours ago, David in Яuislip said: I didn't need regex, it worked set to normal Hello, David. That’s right. Regex (regular expression) can often be avoided. I would advise you, however, against using spaces other than what they were designed for non-breaking spaces, breakable spaces, thin spaces, etc. to avoid problems at the printing stage. Digging into the question of regexes, I find an anomaly. The class \w (alphanumeric characters) is well recognized, as well as \d (numeric characters), but not \a (alphabetic characters only). Fortunately, [a-z] can be used instead of \d, but this is a surprising omission. Quote 6 cœurs, 12 processus - Windows 11 pro - 4K - DirectX 12 - Suite universelle Affinity (Affinity Publisher, Affinity Designer, Affinity Photo). ███ Mais je vous le demande, peut-on imaginer une police sans sérifs ?
Pyanepsion Posted July 3, 2021 Author Posted July 3, 2021 The absence of \a cannot be deliberate, as this would be a major design error. In our business, at least most of us who use DTP software, it is very common to have to rectify cut and paste errors that have added a non-breaking space. Example: In orange, a lot of spaces found by \w that should not be changed. Only the blue spaces, usually found by \a, must be corrected. Quote 6 cœurs, 12 processus - Windows 11 pro - 4K - DirectX 12 - Suite universelle Affinity (Affinity Publisher, Affinity Designer, Affinity Photo). ███ Mais je vous le demande, peut-on imaginer une police sans sérifs ?
walt.farrell Posted July 3, 2021 Posted July 3, 2021 10 hours ago, Pyanepsion said: The absence of \a cannot be deliberate, as this would be a major design error. There are many dialects of regular expressions, with slightly different syntaxes and meanings. It is common to have to learn how to transform a regex that works in one application into one that will work in another application, with a different regex dialect. But considering \a: In most RegEx dialects that I'm used to, the it represents the "BEL" (alarm) character. That includes in Perl and in the Boost library operating in Perl mode (which is relevant for Publisher, I think). I don't think I've ever seen one where \a is anything other than BEL. Here's a good RegEx reference, by the way, to referring to characters: http://www.regular-expressions.info/refcharacters.html It also has a good reference for characer classes. The closest to what you want, I think, is [:alpha:] which I think/ can work in Boost (Publisher) in some cases.http://www.regular-expressions.info/refcharclass.html Pyanepsion 1 Quote -- 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.5, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.5
Pyanepsion Posted July 4, 2021 Author Posted July 4, 2021 \a is indeed originally found more in Vim, a Linux text editor oriented in the manipulation of text files from which most other text editors are inspired. Each variant of Regex is in fact intended for a particular use. However, we work on text. We should therefore be able to easily perform operations such as detecting inappropriate spaces in a string of characters including punctuation, numbers, symbols, superscripts, indices, etc. This is impossible at the moment. The main programming languages, even the most text-oriented ones such as Perl or its successor Python, have unfortunately been developed by programmers who use a mother tongue that does not know all the subtleties of accentuation, and they are not literary. I am afraid that this issue can only be resolved when Serif allows third-party companies to create extensions and provides them with the necessary documentation. Quote Elle était : le Petit Chaperon rouge. Ilª ne le savait pas. 10 spaces must be standard, 1 is a non-breaking space (in front of the colon) and a non-breaking space is missing before the note call. [[:alpha:]] [[:alpha:]] : 7 occurences (83 calculation steps) [[:word:]] [[:word:]] : 7 occurences (83 steps of calculation) (\w) (\w) : 7 occurences (166 steps of calculation) Quote 6 cœurs, 12 processus - Windows 11 pro - 4K - DirectX 12 - Suite universelle Affinity (Affinity Publisher, Affinity Designer, Affinity Photo). ███ Mais je vous le demande, peut-on imaginer une police sans sérifs ?
walt.farrell Posted July 4, 2021 Posted July 4, 2021 2 hours ago, Pyanepsion said: We should therefore be able to easily perform operations such as detecting inappropriate spaces in a string of characters including punctuation, numbers, symbols, superscripts, indices, etc. This is impossible at the moment. Sorry, but I don't understand why it is impossible. And my apologies, but I also do not understand how your example demonstrates this, or what your example demonstrates. Quote -- 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.5, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.5
walt.farrell Posted July 4, 2021 Posted July 4, 2021 25 minutes ago, Lagarto said: so the following would find all special spaces that Affinity apps recognize and would replace them all with a regular space, If you want to replace all special spaces with a normal space, it's even easier. Just replace all spaces with a regular space. Search for \s and replace with a space. Quote -- 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.5, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.5
Pyanepsion Posted July 4, 2021 Author Posted July 4, 2021 5 hours ago, walt.farrell said: If you want to replace all special spaces with a normal space, it’s even easier. Just replace all spaces with a regular space. Search for \s and replace with a space. The usual problem is exactly the opposite. In neat French typography, there are 14 types of spaces, which vary according to punctuation, number, certain types of words, etc. All are of course available in Affinity Publisher. It is common to find inappropriate spaces in client texts. They are usually the result of poor copy and paste. They are easy to replace, but this currently requires a lot of attention to detail and time. Better ergonomics would save a lot of time for all users whose language uses complex typography. There are currently 3 possibilities: Checking each of the space types one by one in the whole text. Very long and with risks of careless mistakes. Using a rather complicated Regex routine. Affinity Publisher only offers the minimum here. Long, but very precise. Using a third-party extension, which Serif still does not allow. Very fast, very precise, and error-free. walt.farrell 1 Quote 6 cœurs, 12 processus - Windows 11 pro - 4K - DirectX 12 - Suite universelle Affinity (Affinity Publisher, Affinity Designer, Affinity Photo). ███ Mais je vous le demande, peut-on imaginer une police sans sérifs ?
Recommended Posts
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.