Jump to content

Recommended Posts

Posted

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.

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)

Posted

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! 

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)

Posted

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.

-- 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

Posted

@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.

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.

Posted

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.

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)

Posted
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?

-- 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

Posted

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?

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

Posted

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. 😀

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)

Posted
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... :)

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

Posted
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

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

Posted

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!) 👍 🙂

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)

Posted
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"

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

Posted
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"

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

Posted
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.

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.

Posted
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:

image.png.84e79f67c8870d668777ace6e4d72e25.png

Next, find the italic double underscores and change them to non-italic double quote marks:

image.png.5645415a63ab935295516b3d53f10434.png

-- 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

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.