Swap between lines of text — GREP?
Learn / Forums / General InDesign Topics / Swap between lines of text — GREP?
Tagged: find/change, GREP, styles
- This topic has 7 replies, 2 voices, and was last updated 6 years, 6 months ago by Masood Ahmad.
-
AuthorPosts
-
-
October 12, 2017 at 1:37 am #98824Kobi BenezriMember
Hello,
In a long text that runs across several text boxes (with columns breaks), I have a situation in which every first two lines in every OTHER text box is wrongly ordered. Let me explain in more detail.
//TEXT BOX 1:
Line 1A – Paragraph Style 1 / Character Style 1
Line 1B – Paragraph Style 1 / Character Style 1//COLUMNS BREAK
//TEXT BOX 2:
Line 2A – Paragraph Style 2 / No Character Style
Line 2B – Paragraph Style 1 / No Character Style
Line 2C – Paragraph Style 1 / No Character Style
//PARAGRAPH BREAK
Line 2D – Paragraph Style 2 / No Character Style
Line 2E – Paragraph Style 1 / No Character Style
Line 2F – Paragraph Style 1 / No Character Style//COLUMN BREAK
//TEXT BOX 3:
Line 3A – Paragraph Style 1 / Character Style 1
Line 3B – Paragraph Style 1 / Character Style 1//COLUMN BREAK
//TEXT BOX 4:
Line 4A – Paragraph Style 2 / No Character Style
Line 4B – Paragraph Style 1 / No Character Style
Line 4C – Paragraph Style 1 / No Character Style
//PARAGRAPH BREAK
Line 4D – Paragraph Style 2 / No Character Style
Line 4E – Paragraph Style 1 / No Character Style
Line 4F – Paragraph Style 1 / No Character Style//COLUMN BREAK
…
TEXT BOX 500
So, what I need is this:
Find:
2A
2B
2CReplace:
2B
2C
2AThe above goes the same for 4A/4B/4C, 6A/6B/6C, 8A/8B/8C, etc.
Essentially it means pushing down 2A two lines down, but the styles also need to be reapplied – 2B, which is now at the top should have Paragraph Style 2, and 2A, with is now at the bottom, should have Paragraph Style 1.
Important notes:
2A and 2B are always letters
2C is always digitsEven if there is an expression that can do this, how do I go about lines 2D, 2E, and 2F? they have identical styles as lines 2A, 2B, and 2C, and the only difference is that they come after a PARAGRAPH BREAK and not a COLUMN BREAK.
It’s a long shot, but I thought I’d give it a try..
Thanks!
-
October 12, 2017 at 9:47 am #98834Masood AhmadParticipant
Can you give some live text or the paragraphs starts with “Line, space digit, Uppercase character, space and en-dash”.
-
October 12, 2017 at 10:17 am #98835Masood AhmadParticipant
As I’ll be leaving shortly, I assume the text is as-is. Try this:
Step 1: This find/change should not be repeated throughout the document. Should be run once only.
GREP Find/Change:
Find What:(^Line \d\u.+\r)(^Line \d\u.+\r)(^Line \d\u.+\r)
Change to:$2$3$1
Step 2: To apply style to the first line.
GREP Find/Change:
Find What:^Line \d\u.+\r(?=(^Line \d\u.+\r){2})
Change Format:Paragraph Style 2
Let me know if this works for you :)
-
October 12, 2017 at 12:50 pm #98841Kobi BenezriMember
Hi Masood,
Thanks for the reply!
The lines actually do not start with ‘Line’, so I suppose this won’t be accurate enough. Examples of live text:
VIA, FR
Folding chair
1972Gebrüder Thonet, DE
Stacking chair
1973/74Wilkhahn, DE
Chair
1974Rosenthal Einrichtung, DE
Rocking lounge chair
1974Bracciodiferro, IT
Chair
1975Studio Mendini, IT
Chair
1975So, as you can see the first line varies – it can be a single word/comma/single word, or it could be multiple words/comma/word, etc. Second line is the only things that somehow repeats, but in many variations (Chair, Armchair, Table, Reclining Chair, Garden Armchair, Storage Unit, Lounge Chair, and so on..), This line is always a date (year in numbers).
Thanks!
-
October 12, 2017 at 12:53 pm #98842Kobi BenezriMember
Looking at it again, the first line almost always (maybe 95% of the time) has a comma, and then a country code (US, FR, DE, IT, CH, BE, etc.). Maybe that’s something to work with? like find a string that ends with [comma]+two UPPERCASE LETTERS as the first line.
What do you think?
-
October 12, 2017 at 1:28 pm #98843Kobi BenezriMember
So, this worked for me:
(\u.+, \u\u\r)(\u.+\r)(\d.+\r)
Now I need to figure out the second part!
-
October 12, 2017 at 1:45 pm #98844Kobi BenezriMember
Solved:
\u.+\r(?=(\d.+\r))
Find Format: Paragraph Style 1
Change Format: Paragraph Style 2
Thanks so much, Masood!
-
October 13, 2017 at 3:35 am #98846Masood AhmadParticipant
That’s great :) I wouldn’t have done it much better than this.
-
-
AuthorPosts
- You must be logged in to reply to this topic.