Target every other carriage return

Learn / Forums / General InDesign Topics / Target every other carriage return

Viewing 6 reply threads
  • Author
    Posts
    • #85119

      I’ve got a huge text file with hundreds of carriage returns. For a very specific reason, I need to target every other, or every nth carriage return.

      Nullam quis risus eget urna mollis ornare vel eu leo
      Donec ullamcorper nulla non metus auctor fringilla ( ? )
      Cras mattis consectetur purus sit amet fermentum
      Sed posuere consectetur est at lobortis ( ? )
      Curabitur blandit tempus porttitor

      I’m a noob to grep, but I figure it’s possible. Any thoughts?

    • #85121
      Ari Singer
      Member

      There are a number of ways to achieve this, but it really depends on what you plan to with it after that. By that I mean: do you plan on removing, editing or adding text? Or do you want to just change some formatting?

      And just to make sure: Are you sure there is no pattern, so for ex. does every other line have something in common which each other?

    • #85132
      David Blatner
      Keymaster

      I agree with Ari that more information would be helpful.
      In the meantime, this article might help:
      https://creativepro.com/find-paragraph-grep.php

    • #85133

      Cool, so the lines are all differing lengths, they don’t seem to have any pattern. I am trying to target each other line to remove the paragraph breaks and replace them with standard spaces.

      It’s an odd project for a client, who wants the entire text of the bible as a texture on wall panelling. I was able to grep out all the references and numbering easily enough, but the line length is too short for the size of panel—three lines or so would be more appropriate for the texture.

      Again, odd project, but the goal would be to strip two of every three paragraph returns out of the entire bible to make line length more conducive to texturing the panel.

      most lines end with a period, but not all. If it makes it easier, then it could be a useful shorthand, I would guess, though not perfect.

      example text:

      And Abimelech charged all his people, saying, He that toucheth this man or his wife shall surely be put to death.
      Then Isaac sowed in that land, and received in the same year an hundredfold: and the LORD blessed him.
      And the man waxed great, and went forward, and grew until he became very great:
      For he had possession of flocks, and possession of herds, and great store of servants: and the Philistines envied him.
      For all the wells which his father’s servants had digged in the days of Abraham his father, the Philistines had stopped them, and filled them with earth.
      And Abimelech said unto Isaac, Go from us; for thou art much mightier than we.
      And Isaac departed thence, and pitched his tent in the valley of Gerar, and dwelt there.

    • #85136
      Ari Singer
      Member

      Try this:

      Find What: (.+)(\r)(.+)(\r)(.+)(\r)

      Change To: $1$2$3$4$5\x{0020}

      But beware, this will only work correctly if you change all at once by clicking Change All.

    • #85137
      Ari Singer
      Member

      I’m sorry please disregard my previous post! I misunderstood what you want. Here is the good code:

      Find What: (.+)(\r)(.+)(\r)(.+)(\r)

      Change To: $1 $3 $5$6 (That’s intentional spaces in there)

      Note: This will work even if you change it one by one, it does not have to be changed all at once.

    • #85138

      Thanks!

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