Adding Quantifiers to Lookaround Operators

Learn / Forums / InDesign User Groups / Adding Quantifiers to Lookaround Operators

Viewing 2 reply threads
  • Author
    Posts
    • #72311
      rich_de_g
      Member

      Hi,

      I have these two strings, below, and I would like to isolate the text, Daily Returns.

      =[Piedmont daily.xlsx]Daily Returns!$C$15
      =Daily Returns!$C$15

      The expression to isolate the bits before Daily Returns is fairly simple:
      \=(\[?.+\])?

      But if I try to encapsulate this in a positive lookbehind operator, it fails. I’ve tried and tried and, well maybe I’m missing something obvious.

    • #72313
      Aaron Troia
      Participant

      Lookbehinds cannot be greedy (ie you cant use quantifiers), lookaheads on the other hand can be greedy, but not lookbehinds, but you can use Keep or \K to mimic the positive lookbehind while using quantifiers, try:

      \=(\[?.+\])?\K.+?(?=\!\$C\$\d+)

    • #72314
      rich_de_g
      Member

      A. A. Ron,

      Thanks, that works great! I’ve never heard of ‘Keep’; I shall have to learn more about it.

      Thanks again,
      Richard

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
>