11 Replies Latest reply on Dec 27, 2011 1:11 AM by LouWrench

    GREP find and Style

    LouWrench Level 1

      It is some thing I get quite a bit of, I import text unstyled, into ID!

      I then do a search for a [A Head] leader to a para and change to "A Head"  para style!

      You get the drift I am sure But... what if get a [Bullet] para return, a list of text to be styled followed by [End Bullet]

      Can this be done with GREP?

      It could make a big difference to my make-up time

      Regards

      Lou

        • 1. Re: GREP find and Style
          [Jongware] Most Valuable Participant

          That'd be this:

           

          Search for

          (?s)\[Bullet\]\r(.+?)\[End Bullet\]

           

          Replace with

          $1

           

          with your bullet paragraph style in Change Format.

          This will remove [Bullet] and [End Bullet] from your text, but it may leave some stray hard returns. If the formatting of your text is entirely consistent (always with or always without a hard return before, after, or both commands), it's possible to Do It Right first time around, otherwise you'll need some manual tidying up.

           

          FYI, the GREP modifier (?s) forces GREP into what's known as 'single line mode'. Never mind the name, it's historical; all it means is the period wildcard . will also match hard returns. In the default mode, a GREP expression stops matching when it encounters a hard return, and in your case you need all paragraphs up to the end command.

          • 2. Re: GREP find and Style
            LouWrench Level 1

            I ws wondering If my question was a bit cryptic!

            What I am doing is importing authors text into the document, I am working on.

            The text is not styled but the required styles are flagged with [A Head], [Body Text] [C head], etc.

            What I then do is search for these flags, I search for eg.

            [AHead]Resources

            then change the hilited text to my style for A Headings, which makes the whole paragraph a A Heading. I do a "change all" and all the A headings in my document are styled.

            The problematic (for me at least) is when we come to eg. Bullet text this will be flagged so


            [bullets]

            Recall information

            Organise or reorganise knowledge

            Use information in a new way

            Critically evaluate scientific information

            [end bullets]


            Is there a way of searching for text between those flags and applying a style to it?

             

            Looking for help

            1 person found this helpful
            • 3. Re: GREP find and Style
              LouWrench Level 1

              Just given it a go, and It cannot find a match!

              Which as an aside I get every now and again, I may search for some repeting bit of text eg.

              a) and find cannot find it! even if I copy and paste into find, still no go!

              So I will try in some other conditions

              Thanks so far

              • 4. Re: GREP find and Style
                [Jongware] Most Valuable Participant

                Well there's your mistake. In your original post, the code was [Bullet] and so I used that to test (and it worked). Now your text contains [bullets] instead. Note also GREP is case-sensitive; you need to put the exact text in the Find string.

                 

                ... It will also find nothing if there may be spaces or tabs or anything else between [bullets] and the hard return at the end of that line.

                1 person found this helpful
                • 5. Re: GREP find and Style
                  [Jongware] Most Valuable Participant

                  As for your "sometimes it finds naught", a lot of characters are 'special' in GREP search strings. If your example 'a)' was used with GREP, the parenthesis was the cause. To find a literal parenthesis, you need to escape it with a backslah: 'a\)'. I did the same with the square braces; also 'special', also needs an escape.

                  • 6. Re: GREP find and Style
                    LouWrench Level 1

                    Hi Jongware

                    Thanks for your persistance.

                    I am copying and pasting the text I am testing on, and copy/paste modified GREP command (who knew about case sensitive in GREP)

                     

                    [bullets]

                    Recall information

                    Organise or reorganise knowledge

                    Use information in a new way

                    Critically evaluate scientific information

                    Categorise information

                    Follow instructions

                    Make observations

                    Record information/data

                    [end bullets]

                     

                    (?s)\[bullets\]

                    (.+?)\[end bullets\]

                     

                    I cannot copy/paste the GREP the \r comes thro' as a return

                    I have re-inserted them in this this

                     

                    (?s)\[bullets\]\r(.+?)\[end bullets\]\r

                     

                     

                     

                    (?s)\[bullets\]

                    (.+?)\[end bullets\]

                    • 7. Re: GREP find and Style
                      [Jongware] Most Valuable Participant

                      This ought to have worked, honestly. Check your text with Hidden characters showing, perhaps there are spaces between the bracketed commands and the hard return. Also, possibly those aren't hard return at all but forced line breaks instead?

                       

                      (InDesign's habit of 'interpreting' special characters when copying out of a GREP has bitten me before. It's even possible you copied a stray space at the end of the expression and pasted that as well. In Case of Doubt: delete the entire Find expression and re-type.)

                      • 8. Re: GREP find and Style
                        LouWrench Level 1

                        Hi

                        Jongware

                        I have had to leave of that problem for another emergency, but will come to it in the week!

                        I think there is more chance of you getting it right and me (or at least my fingers) getting it wrong.

                        I have done a bit of a search, and I cannot find what the command for a "Spacebar" space. Would it be " \" and what is it called?

                        Lou

                        • 9. Re: GREP find and Style
                          [Jongware] Most Valuable Participant

                          A space in GREP is simply one space, like this ->

                          Well I guess you can't see it here! If you select all text in a GREP command, you can see it pop up.

                           

                          Sometimes copying & pasting from a web page inserts spaces at the end of a line when there shouldn't be one. Hence, When In Doubt Delete All and Type.

                           

                          If you still cannot get it to work, try one step at a time:

                          1. Search for \[bullets\] -- if this cannot be found, you're in trouble!

                          2. Search for \[bullets\]\r -- if this can't be found, there might be spaces in your document after the final ']'.

                          3. Search for \[end bullets\] and \[end bullets\]\r -- same as above. In one test of mine this last one failed, but then I realized the final 'end bullets' didn't have a hard return after it because it was at the end of a story!

                          4. If the above works, the complete expression should work as well ...

                           

                          Here is what it should look like -- note I have enabled Show Hidden Characters to make sure there weren't any stray spaces anywhere:

                           

                          Screen Shot 2011-12-18 at 4.52.14 PM.png

                          • 10. Re: GREP find and Style
                            LouWrench Level 1

                            Jongware

                            Many thanks, you time will help me save a lot more of my time

                            Lou

                            • 11. Re: GREP find and Style
                              LouWrench Level 1

                              Jongware

                              Got around to the [bullets] job. searched for extra spaces and it workede like a dream

                              Thanks

                              Lou