0 Replies Latest reply on Jul 14, 2017 8:35 AM by hladdha123

    Regex for GREP search in InDesign script

    hladdha123 Level 1


      I have a set of InDesign documents with records in the following format -


      {item_id}. {item_text} [{tags}] 
      {item_id}. {item_text} [{tags}] 
      {item_id}. {item_text} [{tags}] 

      where item_id is an integer id,

      item_text consists of ( multi-line text block ) ,

      tags consists of single-line text block


      So, now for selecting this group of items I am trying the following regex:


      item = '(([0-9])+\\.\\s+)(\\s|.|\\r)*?(?=[0-9]+\\.\\s)'
      item_text = '[0-9]+\\.\\s+((.|\\r|\\s)*)*?(?=\\[(.)*\\])'
      tags = \\[((.)*)\\]

      here, we are extracting group 1 in item_text, tags regex for the required data.


      So, now with this I am able to get the first n-1 records correctly, but the last record is not getting selected
      since it is not able to find the following id block for the last record i.e. this part of the regex for item - (?=[0-9]+\\.\\s)


      Can someone suggest a better regex to capture all such records including the last one.