PaulEC Posted May 18, 2023 Posted May 18, 2023 I've got a feeling I've seen this somewhere (I might even have asked the question before myself and forgotten the answer!), but is it possible to automatically search a document for "_any words_" and replace it with "any words". In other words, remove the underscores and italicize the word(s) between them. Many thanks for any help. Quote Acer XC-895 : Core i5-10400 Hexa-core 2.90 GHz : 32GB RAM : Intel UHD Graphics 630 : Windows 11 Home Affinity Publisher 2 : Affinity Photo 2 : Affinity Designer 2 : (latest release versions) on desktop and iPad "Beware of false knowledge, it is more dangerous than ignorance." (GBS)
MikeTO Posted May 18, 2023 Posted May 18, 2023 Yes, just paste "_any words_" into Find, type "any words", and from the gear menu for Replace, choose Format > Italic. It should look like this. Quote Download a free PDF manual for Affinity Publisher 2.5 Download a quick reference chart for Affinity's Special Characters Affinity 2.5 for macOS Sequoia 15.2, MacBook Pro 14" (M4 Pro)
PaulEC Posted May 18, 2023 Author Posted May 18, 2023 Thanks for your reply, but, sorry, I didn't make myself clear. I need to search for any words that are between a pair of underscores, make those words italic and remove the underscores on each side. I think it can be done with Regular Expressions, but I have no idea how! Quote Acer XC-895 : Core i5-10400 Hexa-core 2.90 GHz : 32GB RAM : Intel UHD Graphics 630 : Windows 11 Home Affinity Publisher 2 : Affinity Photo 2 : Affinity Designer 2 : (latest release versions) on desktop and iPad "Beware of false knowledge, it is more dangerous than ignorance." (GBS)
walt.farrell Posted May 18, 2023 Posted May 18, 2023 Not sure what you mean by automatically. It's certainly possible to manually search for strings like that, remove the underscores, change to an italic style using Find and Replace with regular expression processing. Barring bugs getting in the way, of course Search: _(.+?)_ Make sure the regular expression option is enabled. Replace: \1 Choose format italic from the gear menu for Replace. Edit: This will find any characters between the underscores. If you really mean any words it would be different. thomaso, Patrick Connor, David in Яuislip and 3 others 4 2 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.2.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1
Old Bruce Posted May 18, 2023 Posted May 18, 2023 @PaulEC, Walt's search term has the ? (question mark) in it to select from Here is an _underscored_ bit of _text_ which could cause problems. with the ? you will find the two words separately. Without the ? you will find from _u... all the way to ...xt_ With the ? you'll get: Here is an underscored bit of text which could cause problems. Without the ? you'll get: Here is an underscored bit of text which could cause problems. PaulEC and walt.farrell 1 1 Quote Mac Pro (Late 2013) Mac OS 12.7.6 Affinity Designer 2.5.7 | Affinity Photo 2.5.7 | Affinity Publisher 2.5.7 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that.
PaulEC Posted May 18, 2023 Author Posted May 18, 2023 Thanks for your help. Basically what I need to do is find all the instances of text which have an underscore at each end and change the formatting of that text to italic. I hoped there might be a way to do it automatically, but if not I’ll just have to do it one at a time (there are several hundred instances in the text I’m working on!) At least I can now search for them, rather than reading through the whole thing and hope I don’t miss any! Thanks again for your help. Quote Acer XC-895 : Core i5-10400 Hexa-core 2.90 GHz : 32GB RAM : Intel UHD Graphics 630 : Windows 11 Home Affinity Publisher 2 : Affinity Photo 2 : Affinity Designer 2 : (latest release versions) on desktop and iPad "Beware of false knowledge, it is more dangerous than ignorance." (GBS)
walt.farrell Posted May 18, 2023 Posted May 18, 2023 2 minutes ago, PaulEC said: I hoped there might be a way to do it automatically, but if not I’ll just have to do it one at a time (there are several hundred instances in the text I’m working on!) The regular expression approach I described should find them all, and Replace All should change them all. Barring, as I said, the possibility of bugs. Where are you having a problem? 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.2.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1
Hangman Posted May 18, 2023 Posted May 18, 2023 Hi @PaulEC, does @walt.farrell's solution not resolve your quest? Based on your description it does for me but equally I may have not completely understood your issue and I'm equally unsure what you mean by 'automatically' over and above Find and Replace? walt.farrell 1 Quote Affinity Designer 2.5.7 | Affinity Photo 2.5.7 | Affinity Publisher 2.5.7 Affinity Designer Beta 2.6.0.3027 | Affinity Photo Beta 2.6.0.3027 | Affinity Publisher Beta 2.6.0.3027 MacBook Pro M3 Max, 36 GB Unified Memory, macOS Sonoma 14.6.1, Magic Mouse HP ENVY x360, 8 GB RAM, AMD Ryzen 5 2500U, Windows 10 Home, Logitech Mouse
PaulEC Posted May 18, 2023 Author Posted May 18, 2023 I haven’t had the chance to try yet, and I may well have misunderstood. I assumed that what Walt said would find the instances, but that I would still have to change the formatting myself. I’m afraid that I’ve never been able to get the hang of Relative Expressions! Anyway, I’ll have a go tomorrow, on my PC, (I’m typing this on my iPad,) and see how I get on. 😀 walt.farrell 1 Quote Acer XC-895 : Core i5-10400 Hexa-core 2.90 GHz : 32GB RAM : Intel UHD Graphics 630 : Windows 11 Home Affinity Publisher 2 : Affinity Photo 2 : Affinity Designer 2 : (latest release versions) on desktop and iPad "Beware of false knowledge, it is more dangerous than ignorance." (GBS)
Hangman Posted May 18, 2023 Posted May 18, 2023 10 minutes ago, PaulEC said: I’m afraid that I’ve never been able to get the hang of Relative Expressions! Anyway, I’ll have a go tomorrow, on my PC, (I’m typing this on my iPad,) and see how I get on. 😀 Walt's 'solution' worked like a treat for me so I think it may for you too... PaulEC 1 Quote Affinity Designer 2.5.7 | Affinity Photo 2.5.7 | Affinity Publisher 2.5.7 Affinity Designer Beta 2.6.0.3027 | Affinity Photo Beta 2.6.0.3027 | Affinity Publisher Beta 2.6.0.3027 MacBook Pro M3 Max, 36 GB Unified Memory, macOS Sonoma 14.6.1, Magic Mouse HP ENVY x360, 8 GB RAM, AMD Ryzen 5 2500U, Windows 10 Home, Logitech Mouse
David in Яuislip Posted May 18, 2023 Posted May 18, 2023 22 minutes ago, Hangman said: Walt's 'solution' worked like a treat for me Worked for me too, I am a bit of a beginner with regex and there are a few different versions but this was perfect in Publisher 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
PaulEC Posted May 19, 2023 Author Posted May 19, 2023 Hi @walt.farrell I just wanted to thank you for your excellent advice. It worked like a charm – exactly what I needed! (and saved me several hours work!) 👍 🙂 walt.farrell 1 Quote Acer XC-895 : Core i5-10400 Hexa-core 2.90 GHz : 32GB RAM : Intel UHD Graphics 630 : Windows 11 Home Affinity Publisher 2 : Affinity Photo 2 : Affinity Designer 2 : (latest release versions) on desktop and iPad "Beware of false knowledge, it is more dangerous than ignorance." (GBS)
thomaso Posted May 19, 2023 Posted May 19, 2023 20 hours ago, walt.farrell said: Search: _(.+?)_ Make sure the regular expression option is enabled. Replace: \1 Just curious: Is it possible to replace the _ into " while applying italics to the entire result + still affect any _instance_ regardless of its text in between? _any word_ -> "any word" Quote macOS 10.14.6 | MacBookPro Retina 15" | Eizo 27" | Affinity V1
Seneca Posted May 19, 2023 Posted May 19, 2023 10 minutes ago, thomaso said: Is it possible to replace the _ into " while applying italics to the entire result + still affect any _instance_ regardless of its text in between? Yes it is. Just change Walt's Replace: \1 with Replace: "\1" thomaso and walt.farrell 1 1 Quote 2017 27” iMac 4.2 GHz Quad-Core Intel Core i7 • Radeon Pr 580 8GB • 64GB • Ventura 13.6.4. iPad Pro (10.5-inch) • 256GB • Version 16.4
Old Bruce Posted May 19, 2023 Posted May 19, 2023 3 hours ago, thomaso said: Just curious: Is it possible to replace the _ into " while applying italics to the entire result + still affect any _instance_ regardless of its text in between? The " will become italic. Quote Mac Pro (Late 2013) Mac OS 12.7.6 Affinity Designer 2.5.7 | Affinity Photo 2.5.7 | Affinity Publisher 2.5.7 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that.
walt.farrell Posted May 19, 2023 Posted May 19, 2023 2 minutes ago, Old Bruce said: The " will become italic. Good point, Bruce. I think it would take a multi-step approach to do it with non-italic quote marks. First, retain the _ characters (or better, change to a double _, __) and make the entire string italic: Next, find the italic double underscores and change them to non-italic double quote marks: Old Bruce 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.2.1, Apple Pencil 2, Magic Keyboard Mac: 2023 M2 MacBook Air 15", 16GB memory, macOS Sequoia 15.0.1
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.