Jump to content

Recommended Posts

Posted

I have a GREP find and replace set up to format certain ends of lines. I use \r or \n  which is working fine on the whole but it's not picking up the last line as it is the section end (§)and not a new line . I can't find a GREP character that includes this despite looking on various GREP sites. Any ideas?

Posted

Here's an example of what I'm trying to solve - I want to delete any hyphen with nothing after it (so bananas and damsons) 

 - +\r picks up bananas but not damsons

Screenshot 2025-03-13 at 15.16.15.png

Posted
11 minutes ago, MikeTO said:

I believe \Z will find the end of a story

Thanks. Away from desk now but will check later 

Posted

One thing to consider is whether or not there is a space after the hyphen. This should work;

(-(\n|\z))|(-( \n| \z))

or you could use \s instead of the simple single space in the second set. This would search for any white space character.

(-(\n|\z))|(-(\s\n|\s\z))

 

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.

Posted
1 minute ago, Old Bruce said:

One thing to consider is whether or not there is a space after the hyphen. This should work;

(-(\n|\z))|(-( \n| \z))

or you could use \s instead of the simple single space in the second set. This would search for any white space character.

(-(\n|\z))|(-(\s\n|\s\z))

 

Thanks - I’ll try this later. GREP saves me so much time but I still always struggle to build the patterns so this will be very useful 

Posted
Just now, RobC said:

...GREP saves me so much time but I still always struggle to build the patterns ...

One of my problems is that there are quite often multiple ways to build a pattern which will do what I want. I find myself trying to find the "best" method, and there isn't actually a "best", just a few different ways to achieve the same result.

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.

Posted

Regarding my earlier claim that often there is no single "best" pattern; @MikeW's is the Best by far. Have a kudos Mike.

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.

Posted
5 hours ago, MikeW said:

One could slightly simplify Old Bruce's pattern using just the end of line character. Makes for a single OR statement:

(-($))|(-\s($))

Capture_001223.png.734c4e553fbd76c3f658f5bc6ceb6b88.png

Both yours and @Old Bruce's solutions work a treat - it's greatly appreciated - I didn't know this end of line character and I think it will help me with another GREP problem that I've posted about before (and had stopped me moving from Publisher 1 to Publisher 2)

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.