2 Replies Latest reply on Jul 25, 2008 2:07 AM by sotospeak (carlo bazzo)

    find text in CS2

    sotospeak (carlo bazzo)
      I have to find all occurrances of strings such as "[art_code]".

      In CS3 it's easy with findGrep where I put myRegexpString="\\[.*\\]"

      Is there any metacharacters which can bring the same results using the .search() CS2 method?

      It seems I can have .search('[^?]') but how can I get "one or more characters inside square brackets"?

      thank you
      carlo
        • 1. Re: find text in CS2
          Level 1
          Hi carlo,

          Since CS2 doesn't have grep searching (CS3 does), you have to mix InDesign searching with JavaScript regular expressions. Here's how it would work:

          1. Read the contents of a story into a JavaScript string.
          2. Use a JavaScript regular expression to find all of the text that matches a pattern. This will produce an array of matches.
          3. Sort the list of matches and then remove duplicate matches from the list.
          4. Then use the InDesign search method to search for the text of the found matches and do whatever it is you want to do. Remember to iterate backwards over the found text objects if you intend to change the text (to avoid invalid references).

          Thanks,

          Ole
          • 2. Re: find text in CS2
            sotospeak (carlo bazzo) Level 1
            you were very informative, thank you Ole.

            carlo