24 Replies Latest reply on Jun 10, 2013 10:45 PM by jerugalhelp

    GREP help

    jerugalhelp

      I need to change the character style of any amount of words..as long as it ends with ":" a collin

       

      I tried doing

      ([\l\u]+:)

      but that only gives me 1 word attached to the collin

       

       

      then I tried:

      ([\l\u]+ [\l\u]+:)

       

      but again that only gives me 2 words nearest to the collin

       

      any ideas on how to get " any word in the paragraph before a collin" ?

       

      THANKS!!!
        • 1. Re: GREP help
          Peter Spier Most Valuable Participant (Moderator)

          You don't really need GREP for this, but ^.+:? should find everything from the start of a paragraph up to the first colon.

           

          But as I said, you don't need the GREP, at least not if you are using paragraph styles. Create a Nested Style in the paragraph style definition and apply it through 1 : and you'll get what you want.

          • 2. Re: GREP help
            jerugalhelp Level 1

            thanks for your response

            I tried both of these ideas

            and for some reason (in both options) everything is changing to my new  character style . its as if its rrading the : as an end of paragraph symbol....

            • 3. Re: GREP help
              Peter Spier Most Valuable Participant (Moderator)

              SOrry, out walking the dog.

               

              I just tested and this GREP expression seems to work better: ^[^:]+:

               

              That's start of paragraph, anything NOT a colon up to and including the first colon. Finds nothing if there is no colon.

               

              The nested style also works just fine, as long as there is a colon in the paragraph. If there is no colon the character style will be applied to the entire paragraph.

              1 person found this helpful
              • 4. Re: GREP help
                jerugalhelp Level 1

                AWESOME!! worked like a dream

                THANK TOU

                this forum is great!

                • 5. Re: GREP help
                  jerugalhelp Level 1

                  another grep equation needed: (PLEASE)

                   

                  I have recipes and would like to put in a tab (or extra space) after the amount needed and before a regular word

                  for example:

                   

                  I have

                   

                  4 quarts chicken soup

                  1 squash

                  1 potato

                  salt to taste

                  2 Tbsp. flour

                  2 Tbsp. oil

                  2 chicken cutlets

                   

                  I would like to put a tab after the 4 , 1 , 1,

                  but BEFORE the word SALT

                  and after 2 , 2 , 2 ...

                   

                  THANK YOU!!!

                  • 6. Re: GREP help
                    SJRiegel Adobe Community Professional & MVP

                    Find ^\d

                    Change to $0\t 

                     

                    will take care of adding the tab after the numbers. I think the salt line would have to be done manually, unless it reads the same in all recipes

                     

                    In that case, you could use a regular find/change for that line.

                    • 7. Re: GREP help
                      Peter Spier Most Valuable Participant (Moderator)

                      I think you could do this all in one expression: ^(\d*)\s*([^\d]) and change to $1\t$2

                       

                      This will find both digit(s) followed by any sort of space(s), just blank space, digit(s) with nothing after them, or nothing at all at the beginning of a paragraph, followed by anything that is not a digit, and insert a tab before the not a digit character, repalcing any space that's already there, if any, which means it can be re-run without adding extra tabs.

                      • 8. Re: GREP help
                        jerugalhelp Level 1

                        Thank you peter!!

                        just one more issue

                        I realized that I have fractions a lot of times (its a cookbook)

                        and when I run this, its treating the fractions as "anything thats not a digit"

                        how do I get it to read fractions as digits?

                        • 9. Re: GREP help
                          Peter Spier Most Valuable Participant (Moderator)

                          Are these "real" fractions (a single glyph) or fractions made by typing a numerator-slash-denominator? We're going to need to define a class, I think, of the possible characters, so we need to know what those possible characters are.

                          • 10. Re: GREP help
                            jerugalhelp Level 1

                            ok well actually some are glyphs and some are not  - the font only came with 3 basics. how lovely does that sound?

                            • 11. Re: GREP help
                              Peter Spier Most Valuable Participant (Moderator)

                              So what are the ones that are real?

                              • 12. Re: GREP help
                                jerugalhelp Level 1

                                1/2 , 1/4 , 3/4

                                • 13. Re: GREP help
                                  Peter Spier Most Valuable Participant (Moderator)

                                  OK, covering all the bases, this looks like it works as long as there are NO spaces between the integer and the fraction: ^([\d¼½¾⅓⅔⅛⅜⅝⅞]*)(\/\d+)*\s*([^\d])

                                   

                                  Change to $1$2\t$3

                                   

                                  If there are spaces between the integer and fraction, I'll need to think some more...

                                  • 14. Re: GREP help
                                    jerugalhelp Level 1

                                    AWESOME!

                                    there are no spaces between integer and fraction. so that was fine

                                     

                                    but now: 2 things

                                    1- what happens by man made fractions? do I need to do it manually? cuz now Im getting the tab before the fraction bar

                                     

                                    2- for some reason Im getting a "$2" before the Salt example instead of a tab

                                     

                                     

                                    thanks thus far!

                                    • 15. Re: GREP help
                                      Peter Spier Most Valuable Participant (Moderator)

                                      I'm not sure what the problem is. It's working correctly here. You should copy that expression from the forum page (or you can rebuild it by copying and pasting the fraction glyphs from a text frame into position between the \d and the ] and forget about the fractions that you don't have). the (\/\d+) is there to pick up the slash and denominator in your manmade fractions, so there should be nothing else to do. Can you post a screen shot of the text that isn't working correctly before you run the query, with non-printing characters showing? It might give me a clue what went wrong for you.

                                      • 16. Re: GREP help
                                        jerugalhelp Level 1

                                        here you can see the $2 added before salt...Screen Shot 2013-06-10 at 1.46.30 PM.png

                                         

                                         

                                         

                                        Screen Shot 2013-06-10 at 1.48.08 PM.png

                                        and here you can see my man made fraction...torn apart with a tab

                                        • 17. Re: GREP help
                                          Peter Spier Most Valuable Participant (Moderator)

                                          I need to also see the "before" versions, and the find/change dialog.

                                          • 18. Re: GREP help
                                            Peter Spier Most Valuable Participant (Moderator)

                                            And it seems odd that there's no tab in the broccoli line....

                                            • 19. Re: GREP help
                                              jerugalhelp Level 1

                                              no tab in the broccoli line bec I was doing it line by line - find and change find and change - so dont worry about that

                                               

                                              here are the screenshots

                                               

                                              Screen Shot 2013-06-10 at 2.18.19 PM.png

                                              Screen Shot 2013-06-10 at 2.18.37 PM.pngScreen Shot 2013-06-10 at 2.18.59 PM.png

                                              • 20. Re: GREP help
                                                Peter Spier Most Valuable Participant (Moderator)

                                                OK, I think we've found a bug. As far as I can tell there's nothing wrong with the way you set up. When I do a Change All it works as expected, but when I switch to Change/Then Find, I get the same $2 added. If I change the scope to selection and highlight the salt line alone or in conjuction with any other lines, and do a Change All, it also works. It's only failing with find followed by a change line by line.

                                                 

                                                I'm not seeing the failure on a manmade fraction, though. Would you be willing to send me a copy of a page or two where this is happening to see if I can reproduce it on your file instead of my own?

                                                • 21. Re: GREP help
                                                  jerugalhelp Level 1

                                                  ok thank you ever so much!

                                                  where do I send the file to?

                                                  • 22. Re: GREP help
                                                    Peter Spier Most Valuable Participant (Moderator)

                                                    I've sent you some instructions and an upload link.

                                                    • 23. Re: GREP help
                                                      Peter Spier Most Valuable Participant (Moderator)

                                                      Got your file and found the problem with the man-made fractions. You are more sophiticated than I was -- you're using a real fraction slash character (unicode 2044) and used a plain slash. No problem.

                                                       

                                                      Try ^([\d¼½¾⅓⅔⅛⅜⅝⅞]*)(\x{2044}\d+)*\s*(\D) and change to $1$2\t$3, but you need to take that leap and use Change All to avoid the bug with the $2 appearing when there is no number at the start.

                                                       

                                                      You also should get rid of the empty paragraphs (use space before or space after to separate paragraphs instead). If you must use the blank paragraphs, at least change the paragraph style -- a blank paragraph is picked up as the optional white space and will be deleted if it falls before a paragraph that doesn't start with a number.

                                                       

                                                      You might notice too, that I changed [^\d] to \D in the last sub-expression. Means the same thing (I'd forgotten about negation of wildcards by using capitalization).

                                                      • 24. Re: GREP help
                                                        jerugalhelp Level 1

                                                        WOW!!! Adobe has the best forum! Peter this is just AMAZING!

                                                        I really appreciate your time and effort!