17 Replies Latest reply on Jul 22, 2014 10:45 AM by pixxxel schubser

    GREP modifiers

    aaronmanson

      Ok here is my question

       

      I have currently created a grep (with my limited understanding of them) to do the following in indesign - see below

       

      Apply style: Bolding_Text

      \<price\>|\<agent\>|\<inspect\>|\<auction\>|\<address\>

      then it applies a bold text to the selected worlds.

      I am not trying to take off the case sensitivity to allow the bold text character style to be applied to the word\s irrespective of the case.

      Ie agent and AGENT (when typed in)

       

      is this even possible ?

      i thought this might work but hasn't

       

      (?¡)\<price\>\<agent\>|\<inspect\>|\<auction\>|\<address\>

      I would be most appreciative if someone could either expand or dismiss my concern

       

      thanks in advance

      \<price\>|\<agent\>|\<inspect\>|\<auction\>|\<address\>

      \<price\>|\<agent\>|\<inspect\>|\<auction\>|\<address\>

      \<price\>|\<agent\>|\<inspect\>|\<auction\>|\<address\>

      i thought

        • 1. Re: GREP modifiers
          aaronmanson Level 1

          figured it out -- all good

           

          for the record its like this:

          (?i)price:|(?i)address:|(?i)inspect:|(?i)auction:|(?i)agent

          • 2. Re: Re: GREP modifiers
            pixxxel schubser Level 5

            This should be faster and better for you:

            (?i)\b(a(ddress|gent|uction)|inspect|price)\b(?-i)

            • 3. Re: Re: GREP modifiers
              aaronmanson Level 1

              hey thank you so much for that - that one works way better.

              thanks

              • 4. Re: Re: GREP modifiers
                aaronmanson Level 1

                just another question?

                how would i get that to recogise the words with ":" for example agent:     address: etc?

                would i just (?i)\b(a(ddress|gent|uction)"\:"|inspect|price)"\:"\b(?-i)

                would that work?

                • 5. Re: GREP modifiers
                  aaronmanson Level 1

                  just another question?

                  how would i get that to recogise the words with ":" for example agent:     address: etc?

                  would i just (?i)\b(a(ddress|gent|uction)"\:"|inspect|price)"\:"\b(?-i)

                  would that work?

                  • 6. Re: GREP modifiers
                    Eugene Tyson Adobe Community Professional & MVP

                    This seems to work

                     

                    ((?i)(address|gent|auction|inspect|price)([:|^:]|(?!:)))

                    • 7. Re: GREP modifiers
                      [Jongware] Most Valuable Participant

                      That would only work if the double quotes also appear in your text. You don't need them; they are not doing anything special in GREP, they will match just themselfs.

                       

                      The same goes for the colon ":", it is not a special character in GREP and you don't need a backslash to escape it.

                       

                      This suffices:

                       

                      (?i)\b(a(ddress|gent|uction)|inspect|price):

                       

                      The \b "word break" at the end is not needed -- arguably, it is harmful there, because on its left there already is Not A Letter, so on its right there Must Be A Letter. "On one side Not A Letter and on the other side Must Be A Letter" is the definition of this function.

                       

                      All individual GREP style always start in their default mode, so there is no reason to "reset" the Ignore Case mode.

                      • 8. Re: GREP modifiers
                        Obi-wan Kenobi Adobe Community Professional

                        Hi Jongware,

                         

                        I prefer:  (?i)\b(address|agent|auction|inspect|price)\b:?

                         

                        Using only one \b at the beginning, the regex will find, e.g., "inspect"or.

                        • 9. Re: GREP modifiers
                          Eugene Tyson Adobe Community Professional & MVP

                          I don't understand the the 2 \b?

                           

                          ((?i)(address|gent|auction|inspect|price)\b([:|^:]|(?!:)))

                           

                          This addressed the problem of "inspector" or "addressing"

                           

                          Now it only finds the "inspect" or "addressing.

                          • 10. Re: GREP modifiers
                            Obi-wan Kenobi Adobe Community Professional

                            Hi eugene,

                             

                            Try: Curagent

                             

                            [CurAgent is a medical services company at Berlin, Germany] 

                             

                            As our French Master-Jedi Laurent Tournier writes in his book on "Grep et InDesign":

                             

                            \bmin finds minutier, ministre, min, minuscule, éliminer, cumin, examinateur.

                            min\b finds minutier, ministre, min, minuscule, éliminer, cumin, examinateur.

                            \bmin\b finds minutier, ministre, min, minuscule, éliminer, cumin, examinateur.

                            • 11. Re: GREP modifiers
                              Eugene Tyson Adobe Community Professional & MVP

                              Oh I see

                               

                              ((?i)\b(address|gent|auction|inspect|price)\b([:|^:]|(?!:)))

                               

                              This resolved

                              • 12. Re: GREP modifiers
                                Obi-wan Kenobi Adobe Community Professional

                                Eugene,

                                 

                                I understand what you mean by : "([:|^:]|(?!:))"

                                 

                                But why so complicated? use ":?" is easier to understand.

                                • 13. Re: GREP modifiers
                                  Eugene Tyson Adobe Community Professional & MVP

                                  I don't know why, but in InDesign CS5.5 it doesn't work for me.

                                  • 14. Re: GREP modifiers
                                    Obi-wan Kenobi Adobe Community Professional

                                    I see! Maybe CS5.5 has gone to the dark side of the Force! 

                                    • 15. Re: GREP modifiers
                                      pixxxel schubser Level 5

                                      No no. CS5.5 is on the right side. (my friend at work)

                                       

                                       

                                      Grep_agent_price.png

                                       

                                      But one question to aaronmanson:

                                      Perhaps do you want to do something like this? This will be faster and better with nested styles:

                                      Grep_agent_but-nestedstyle.png

                                      Have fun

                                       

                                      • 16. Re: GREP modifiers
                                        aaronmanson Level 1

                                        yes I use nested styles on most occasions.

                                        Thanks for the tips they have been really helpful (in me understanding the GREP language) as I am new to the format

                                        I also was using this one to act on a paragraph style:

                                         

                                         

                                        Apply style: white_1x1A
                                        ^([A-Z ]+)(?![a-z0-9])

                                         

                                        I just used it to make apply a style to capitals only...pretty cool

                                        • 17. Re: Re: GREP modifiers
                                          pixxxel schubser Level 5
                                          this has nothing to do with your first post? (Perhaps a new thread is a better place for a further discussion.)

                                          But you will see, you can define different greps to get the same result.

                                          This is yours:
                                          ^([A-Z ]+)(?![a-z0-9])

                                          search for the A-Z capital letters at the beginning of paragraph which are not following of any small letter a-z or a digit 0-9

                                          Grep does the following:

                                          - Is this the beginning of a paragraph? Yes -->

                                          - Is the first sign the capital letter A? No -->

                                          - Is the first sign the capital letter B? No -->

                                          - Is the first sign the capital letter C? No -->

                                          … and so on

                                          - Is the second sign the capital letter A? No -->

                                          - Is the second sign the capital letter B? No -->

                                          - Is the second sign the capital letter C? No -->

                                          … and so on

                                          … and so on

                                          - Is the (next following) sign not the small letter a? No -->

                                          - Is the (next following) sign not the small letter b? No -->

                                          … and so on

                                          - Is the (next following) sign not the digit 0? No -->

                                          - Is the (next following) sign not the digit 1? No -->

                                          … and so on


                                          And this grep:
                                          ^\u+(?![\w])
                                          should should give you the same result, but a little bit more efficient.
                                          search for any capital letters (more times) at the beginning of paragraph which are not following of any (word element??) /* sorry, I don't know if this is the correct english translation */

                                          Grep does the following:

                                          - Is this the beginning of a paragraph? Yes -->

                                          - Is the first sign a capital letter? YES -->

                                          - Is the second sign a capital letter? YES -->

                                          … and so on

                                          - Is the (next following) sign a word element? No --> // and … this sign can't be a capital letter

                                          … and so on

                                          Have fun