3 Replies Latest reply on Dec 8, 2010 2:35 AM by SimonLinden

    Find string with varying numbers


      I have a long unformatted text which regularly has references which should be in italic. These references look like this:

      Lag (int:int)

      where int represents an integer. (eg. Lag (2009:74) or Lag (2010:347)).


      I would like a script which finds all of these strings and applies a character style to it.


      I have no experience of ID-scripting but I know actionscript so if somebody has a script which does something similar to this I could probably tweak it to fit my needs.

        • 1. Re: Find string with varying numbers
          Kasyan Servetsky Level 5

          I think you can achieve this without script.


          In Find/Change GREP use the following settings:

          Find what: Lag\s\(\d+:\d+\)

          Change to: leave empty

          Change format: Font style > Italic




          P.S. I am not an expert in GREP, may be someone knows a better solution

          • 2. Re: Find string with varying numbers
            [Jongware] Most Valuable Participant

            Your GREP is fine, except it only looks for the name "Lag"! Slightly better:




            which picks up any first word right before the reference. Even better still:




            so it will pick up "Gell-Mann (1964:155)". And yet even better (but at this point it's going to depend on what your references actually look like):




            so it will pick up "Gell-Mann (1964:155-156)" as well. But at some point things gets too complicated to automatically replace. This GREP will not match "Watson & Crick (1953)", for example. (On seeing this, it's actually simple to add this particular variant to the GREP string; I meant to point out there are lots of different ways write any reference.)



            It's also a far better idea not to simply change to Font style > Italic, but to a character style instead (as the OP notes).

            • 3. Re: Find string with varying numbers
              SimonLinden Level 1

              Thanks alot!

              Didn't know about GREP. Will be a great help.