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 MULIT LINE SEARCH

Return to Member Forum

  • Author
    Posts
    • #56669
      damiang
      Participant

      Here's hoping that a grep guru can help me with a “simple” multiline search. The text has been marked up with simple style opening and closing “tags” that are in angle brackets. I can work it out for a single line, but the multiline has me stumped.

      Search for:

      <XYZ>¶

      Text of some kind¶

      More text of some kind¶

      And possibly more text, infact more lines until I reach this marker:¶

      </XYZ>

      and then I will apply a paragraph style in the replace option.

      Many thanks

      Damian

    • #56670
      Anonymous
      Inactive

      This seems to work in some cases

      (?<=x{003E})r+(.+r)+(?!x{003E})

      (?<=x{003E}) this is – (?<=) represents a search behind but don't include in the results

      x{003E} is the unicode for a “>”

      r this is – a paragraph return

      + this is – keep finding as many times as possible

      (.+r)+ this is – find any text follwed by a return as many times as possible

      (?!x{003E}) this is – Look ahead but don't include in the result

      x{003E} is the unicode for a “>”

      And that seems to do the trick of highlighting everthing between the tags

    • #56672

      Slightly easier is to use the Single-Line Modifier ?s — this puts GREP into “single line mode”, where ^ and $ will match start/end of story, and the period may also match a hard return (which it does not by default):

      (?s)(?<=<XYZ>).+?(?=</XYZ>)

      Afterthought: this will also apply the paragraph style to the first line containing the marker. If you don't want that and it's always followed by a hard return, use this:

      (?s)(?<=<XYZ>r).+?(?=</XYZ>)

    • #56673
      Anonymous
      Inactive

      I knew there was an easier way :D

    • #56674
      damiang
      Participant

      THANKS! Works perfectly. Another one to add to my grep list.

      Cheers

      Damian

    • #56675
      Anonymous
      Inactive

      Jongware – I thought that the <XYZ> was just sample text.

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