Skip to main content
jacobg15973780
Participant
July 23, 2024
Answered

GREP Style Problem with Carriage Returns

  • July 23, 2024
  • 3 replies
  • 898 views

I make wine menus and I'm creating a template using GREP styles that will allow me to copy and paste a full menu from Excel into InDesign with character styles applied to all the right bits so they can be quickly personalised. I got it working perfectly on the prices, but on the wine descriptions which appear on the line after prices, I'm having no luck.

 

Here's basically what it looks like for a single wine:

 

Wine Name Here     £2.50     £5.50     £8.50     £20.00
Wine description text here.

 

I'm trying to make it locate the description line by having it first find a price (£\d+.\d+) followed by a carriage return (~b), then start applying the character style (\K) to any set of characters till the end of the paragraph (.+\r)

 

I'm sure this should work, and it works just fine if I use this code in GREP find & replace instead, but it just won't apply it as a GREP style. Like I said, I've got formatting for the prices working perfectly. I've tried deleting the prices' GREP code to make sure it wasn't interfering, but I'm positive that it's down to the carriage return. 

 

Can you just not apply GREP styles that involve carriage returns, or can anyone see if I'm doing something wrong? 

 

Thanks

This topic has been closed for replies.
Correct answer jacobg15973780

Hi, Joel. Thanks for the response. I went to Data Merge first because I've been using it for a lot of things recently, but it's not been useful for this specifically because I need all my records in the same text box and on the same page. Next Style seemed like a good call but didn't work either because it applies the first paragraph style to all of the copy-pasted content. 

 

I've actually figured out a solution using GREP after sleeping on it by avoiding searching over the carriage return. Because copying and pasting my list from Excel carries over a bunch of tabs into the end of my Wine Description line, I've located that line using this: ^.+\t+\r and it does the job just fine. Now I just need to make sure those tabs don't cause me any spacing issues!

3 replies

James Gifford—NitroPress
Legend
July 23, 2024

I'm not all all following your GREP description. I'd use a positive lookbehind to locate the end of the price string through the paragraph return, then select the next whole sentence. I am not quite sure what you're doing with \K, there. 🙂

Robert at ID-Tasker
Legend
July 23, 2024
quote

I'm not all all following your GREP description. I'd use a positive lookbehind to locate the end of the price string through the paragraph return, then select the next whole sentence. I am not quite sure what you're doing with \K, there. 🙂


By @James Gifford—NitroPress

 

It's not about Find&Change - GREP Styles are limited to a single paragraph - but I'm pretty sure you know that. 

 

Robert at ID-Tasker
Legend
July 23, 2024

@jacobg15973780

 

Joel is right - would be best if you can show us your Excel file.

 

Joel Cherney
Community Expert
Community Expert
July 23, 2024

I think that the shortest answer possible is that a GREP style is part of a Paragraph Style, by definition. So that \r marks the end of the paragraph style. Your GREP style can't apply beyond the \r, because everything beyond that \r is in a different paragraph. That paragraph has its own paragraph style, right? 

 

Would you like a longer answer? I can think of at least four different ways you can achieve your desired effect, but all of them involve very different workflows. How wedded are you to the copy-a-whole-Excel-spreadsheet part of your workflow? I'm guessing that you probably have already invested some effort into making layouts in Excel, because if I had a bunch of wine price lists trapped in Excel and I wanted to make it Very Easy to turn those Excel price lists into beautiful InDesign layouts, I'd use Data Merge. But if I had a bunch of well-formatted price lists in Excel and I needed for some reason to move them to InDesign, I'd... probably just destroy all of that formatting work in Excel, and use Data Merge. 

 

If I had compelling reasons to not use Data Merge, I think I might try to use Next Style (which automatically applies a given paragraph style to the following paragraph). I don't know if that would work, never having ever copied entire Excel spreadsheets into InDesign. Perhaps you could tell us a little bit more about exactly how you are setting up your Excel file and your InDesign file. When I play around with it, I find that my clipboard brings in tab-delimited raw text when I copy and paste from Excel. If that's what you are doing yourself, then you can choose "Apply style, then next style" from the context menu when you right-click on a style in your Paragraph Styles panel. 

 

jacobg15973780
jacobg15973780AuthorCorrect answer
Participant
July 24, 2024

Hi, Joel. Thanks for the response. I went to Data Merge first because I've been using it for a lot of things recently, but it's not been useful for this specifically because I need all my records in the same text box and on the same page. Next Style seemed like a good call but didn't work either because it applies the first paragraph style to all of the copy-pasted content. 

 

I've actually figured out a solution using GREP after sleeping on it by avoiding searching over the carriage return. Because copying and pasting my list from Excel carries over a bunch of tabs into the end of my Wine Description line, I've located that line using this: ^.+\t+\r and it does the job just fine. Now I just need to make sure those tabs don't cause me any spacing issues!

Robert at ID-Tasker
Legend
July 24, 2024

@jacobg15973780

 

Any chance you can show us an example of the Excel? Just for fun. We like brain teasers.