Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP help – duplicate lines of text

Return to Member Forum

  • Author
    Posts
    • #68398

      Hello,

      Is it possible to duplicate lines of text with GREP? Here is exactly what I would like to do; I have a list of letters and numbers that looks like this:

      R1H3BOA2HA4
      R1H3BOA2H4
      R1H2H3BO4

      And I need it to be like this:

      R1H3BOA2HA4=R1+H3+BOA2+HA4
      R1H3BOA2H4=R1+H3+BOA2+H4
      R1H2H3BO4=R1+H2+H3+BO4

      So basically I would like to duplicate every line, add the = symbol between the original and the copy and then add + after the numbers of the copy except for the last number. I understand how GREP works but I’m very bad with the syntax.

      Any idea? Thank you for your help!

      DGonzalez

    • #68406
      David Blatner
      Keymaster

      Sure, but you need to be crystal clear about what the patterns are. Can you describe the pattern? Is it always “R1”? Or is it “R” followed by one digit? Or sometimes two digits? I see a “BO” in one place and a “BOA” in another. GREP is powerful, but only if there is a very clear repeatable pattern of text that you can search for.

      • #68407

        It’s “one or more letters” followed by one digit, repeated four times. I found what I was looking for:

        ([\u]+?\d)([\u]+?\d)([\u]+?\d)([\u]+?\d) replaced by $1$2$3$4=$1+$2+$3+$4

        I see how powerful GREP can be and will do my homework on getting the syntax right. Thanks a lot for the quick reply.

Viewing 1 reply thread
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads