Swap between lines of text — GREP?

Learn / Forums / General InDesign Topics / Swap between lines of text — GREP?

Viewing 7 reply threads
  • Author
    Posts
    • #98824
      Kobi Benezri
      Member

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

      Replace:
      2B
      2C
      2A

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

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

    • #98834
      Masood Ahmad
      Participant

      Can you give some live text or the paragraphs starts with “Line, space digit, Uppercase character, space and en-dash”.

    • #98835
      Masood Ahmad
      Participant

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

    • #98841
      Kobi Benezri
      Member

      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
      1972

      Gebrüder Thonet, DE
      Stacking chair
      1973/74

      Wilkhahn, DE
      Chair
      1974

      Rosenthal Einrichtung, DE
      Rocking lounge chair
      1974

      Bracciodiferro, IT
      Chair
      1975

      Studio Mendini, IT
      Chair
      1975

      So, 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!

    • #98842
      Kobi Benezri
      Member

      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?

    • #98843
      Kobi Benezri
      Member

      So, this worked for me:

      (\u.+, \u\u\r)(\u.+\r)(\d.+\r)

      Now I need to figure out the second part!

    • #98844
      Kobi Benezri
      Member

      Solved:

      \u.+\r(?=(\d.+\r))

      Find Format: Paragraph Style 1

      Change Format: Paragraph Style 2

      Thanks so much, Masood!

    • #98846
      Masood Ahmad
      Participant

      That’s great :) I wouldn’t have done it much better than this.

Viewing 7 reply threads
  • You must be logged in to reply to this topic.
>