4 Replies Latest reply on Apr 12, 2015 3:15 AM by pixxxel schubser

    Ignore Line break in find text using grep

    johnp45247251 Level 1

      Hi everyone!

       

       

      I need to find the text in document using grep.

       

      find text for :

       

      Xereptatiuria que alique volo eium qui dolupid ut

      voluptatiam earum saestorepel iuscit im quas et modisimodit.

       

       

      The above sentence cannot having line breaks. But document having multiple line breaks.

       

      so, please to give a tip to find the text using grep.

       

       

      I am not excepting this type of result by following.

       

      Xereptatiuriaque\n alique volo\neium qui dolupid ut\r voluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.  ------------this is not.

       

       

       

      Any another way to find (i.e)., ignore the line break

       

      simply like this, 

       

      (?s:Xereptatiuria que alique volo eium qui dolupid ut

      voluptatiam earum saestorepel iuscit im quas et modisimodit.)      --------- the line break wherever it is found,ignore line break in single command.

       

       

      Screen Shot 2015-04-11 at 6.42.55 AM.png

       

       

       

      Thanks by,

       

       

      John Peter.

        • 1. Re: Ignore Line break in find text using grep
          Peter Spier Most Valuable Participant (Moderator)

          I think your first search string would work if you changed "volo\neium qui dolupid ut\r voluptatiam" to volo\n eium qui dolupid ut \rvoluptatiam" (you need to be very careful about where the spaces are).

          • 2. Re: Ignore Line break in find text using grep
            pixxxel schubser Level 5

            johnp45247251,

            what do you really want to do?

             

            Like Peter Kahrel in your other thread Find Grep And Ignore the line break said:

            pkahrel schrieb:

             

            You're a moving target: you change your question in each post. Do yourself a favour and go and read up on GREP.

             

             

            -------------------------------------------------------------

            johnp45247251, one question:

            Could it be possible, that you doesn't understand correctly, how Grep really works?

             

            <edit by pixxxel schubser>

            Furthermore your example text is different to your screenshot. Your text is:

            »Xereptatiuriaque\n alique volo\neium qui dolupid ut\r voluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.«

            And your screenshot shows:

            »Xereptatiuriaque\n alique volo\n eium qui dolupid ut \rvoluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.«

            Normally the text should look like this:

            »Xereptatiuriaque\nalique volo\neium qui dolupid ut\rvoluptatiam earum\nsaestorepel iuscit im quas et\nmodisimodit.«

             

            Please explain what do you really want to do and exactly if additional spaces are exists or not!

            Could it be:

            you have a text with paragraphs and with many line breaks in that paragraph and there are no spaces exists before or after your line breaks. And is your destination to remove all the line breaks from your text?

            </edit by pixxxel schubser>

             

            Then the way is not to find the text completly and to ignore the line breaks – the way is to find the line breaks and replace with a space, e.g. like that:

            find:

            \n

            replace with:

            \s

            (change all)

             

            Regards

            pixxxel schubser

             

            • 3. Re: Ignore Line break in find text using grep
              [Jongware] Most Valuable Participant

              >  Then the way is not to find the text completly and to ignore the line breaks ..

               

              There is, and it has been suggested before here and on other forums where magically the exact same question appeared. So the OP needs to clarify why none of the suggestions so far work. The best one yet, doing exactly what he appears to be asking, is

               

              (?s)Xereptatiuria\s+que\s+alique\s+volo\s+eium

               

              i.e. by changing each space to "one or more whitespace codes".

               

              I strongly suspect OP is confusing searching for with what will be found -- somehow he expects the 'found text' to not contain the line breaks at all. That is not how "search" works, though.

              • 4. Re: Ignore Line break in find text using grep
                pixxxel schubser Level 5

                [Jongware] schrieb:

                 

                … The best one yet, doing exactly what he appears to be asking …

                 

                 

                 

                My crystal ball is freshly polished - I hope good enough.