2

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!

1

here is the pattern to match this matches any character one or more times followed by a number (repeated 4 times), the parentheses saves that value then you can recall those saved values with $ and then the corresponding number of the saved value e.g first $1 second $2

([\l\u]+?\d)([\l\u]+?\d)([\l\u]+?\d)([\l\u]+?\d)

this is your replace $1$2$3$4=$1+$2+$3+$4

using indesigns grep menu the (@) symbol in the find and replace dialog can help with the syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.