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

Need regex help

Return to Member Forum

  • Author
    Posts
    • #33644
      Jaime Zuniga
      Member

      I receive InDesign files that are formatted like the following:

      English text (with its own formatting)
      Spanish translation (with a different formatting than above)

      What I am looking to do is this:
      English text (with its own formatting)
      English text (with a different formatting than above)

      That is, I want to replace the existing formatted Spanish text with a copy of the English text, but maintaining the formatting of the Spanish text.

      I am trying to do a search and replace in InDesign, using GREP, as follows:
      Search for: (.+)\r(.+)
      Replace with: $1\r$2

      Which essentially finds every instance of the bilingual text, but replaces both English instances with the formatting from the Spanish text.

      Any help in the right direction would be appreciated,
      Jaime

    • #33655
      Matt Mayerchak
      Participant

      Jaime,
      The problem is that you are finding both sets of the English text, so that when you apply formatting to what you find, you apply that to everything. You could be using a positive look behind command to find only the Spanish text, but then it won’t have the English text to replace it with.

      Without seeing your document, it looks like this may require a multi-step process to isolate the Spanish text, because if there is only one return between each set of paragraphs, and they just alternate, Find/Change may not be able to tell which ones to trap and which to ignore. Is there anything unique about the Spanish? Sounds like it has unique formatting – if you can search for that and apply a unique paragraph style to it, that would be a good start.

      Then, you can find all of the Spanish and add something unique before it, such as ???, then you could do the (.+)\r???(.+) and replace with $1\r???$1 (replace what would be $2 with $1. Then you could reapply the Translation paragraph style to all paragraphs that begin with ???, and then remove all of the ???.

      Again, without seeing your document, this is an approximation, but the idea is that you need to do something to make the Spanish text unique so that you can replace it.

      • #33657
        Jaime Zuniga
        Member

        Hi Matt,

        Thanks for replying. The Spanish text does have a unique character format in that it is gray color, but the font style and size is different throughout. That is the problem in that I cannot just create one character style to apply to it. It would have to match the existing font style and size already present in the Spanish.

        Thanks,
        Jaime

    • #33659
      Matt Mayerchak
      Participant

      So is the Spanish formatting different in different places? And is it always the same as its English counterpart?

      I’m having a hard time visualizing what this document is supposed to look like when it’s done.

      Sound like you are trying to create 2 sets of the same text, but with different formatting? But,not all of the Translated (or 2nd set of English) text has the same format – is that right?

      Are all the pairs of English paragraphs supposed to look the same?

      Or are all of the “English 2” paragraphs supposed to look the same?

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