2 Replies Latest reply on Jul 8, 2013 3:11 PM by pcbaz

    Is it possible to use wildcards to match cell contents in an if statement?


      I need to return a ID along with some other information on a page by page basis, so that the information comes out linked by position.  I use a couple of loops and if statements to navigate through the document.  I am able to use exact matches of cell contents which is fine when the contents doesn't vary.  But the IDs, though they have a similar pattern, are all different. In a menu driven search, I am able to find what I need with '150^9^9^9^9^9-^9^9^9' But when I try putting this (or any number of [0-9], *, ? combinations) it fails.  Is it possible to use wildcards?  The symbol used for the match (==) makes me suspect that it is not possible and that only literal, exact matches will work.  But I wanted to check with the experts before giving up.




        • 1. Re: Is it possible to use wildcards to match cell contents in an if statement?
          Peter Kahrel Adobe Community Professional & MVP

          You need to use GREP searches, not text searches. Your post suggests that you're not familiar with GREP, and you could do yourself no bigger favout than learning some basics. Try this search pattern in the GREp tab of the Find/Change dialog:




          \d stands for 'digit', + stands for 'one or more', so \d+ stands for 'one or more digits', i.e. any number. The question mark stands for 'shortest match' -- you'll have to read up on that yourself.


          In a script you would use this:


          app.findGrepPreferences.findWhat = /150\d+?-\d+/.source



          • 2. Re: Is it possible to use wildcards to match cell contents in an if statement?
            pcbaz Level 1

            Thanks for the input.  You're right, a GREP search is much more efficient.  But what I'm trying to do and the circumstances here don't allow me, I think,  to go that route. I am trying to generate a list of values coming from several textframes on a single page and have them come out so that I can tell which values belong together.


            I'm using an inherited document with masters that were created 'manually';  the index numbering for textframes and tables is random. I navigate through the pages, looping through textframe indices asking ' does this textframe exist?' If so, I ask if it is a table -- if no, it is a simple textframe and I ask about the ID, if yes, I ask if the contents of cell (0,0) (invariant position and contents) are equal to the table I want..  I am sending the ID and other pieces of information from the table to one row of a new table on a new page.  So the ID and other information from a single page are linked by being in the same row.


            I know this a little 'off-normal' -- I'm using the search to navigate through the document and find things by location the way you do with a spreadsheet.  I have devised a work-around that helps me get around the fact that the ID is not invariant.  I create a list of the (exact) IDs from another document, equating them to a variable ('a').  I then loop through the list of IDs and ask if the contents of the textframe is equal to 'a'..This works o.k, unless there happens to be an extra space, a different kind of hyphen, etc. It would be so much easier if I could use the wildcards that work in a menu-driven text or GREP search in script just to ask about the contents of the textframe.


            Thanks again

            pcbaz (Peter BIerly)


            P.S. we have since rewritten the masters so this problem will not exist in the future -- we now know exactly which textframe and/or table indices to refer to to get any particular bits of information and don't need to ask questions about the contents.