2008/12/7 Harold Fuchs <[EMAIL PROTECTED]>

> On 07/12/2008 11:16, Johnny Rosenberg wrote:
>
>> I have tried almost everything, but I just can't get this particular
>> search
>> to find anything (I know it's there to find, because I can find it
>> manually…).
>>
>> The search string I want to find looks like this, kind of:
>>
>> The text "</configItem>", sometimes followed by a space but not necessary.
>> Then a paragraph break, then zero or more spaces and then the text
>> "</layout>".
>>
>> Here's an example, I don't know if all spaces etc makes it through all the
>> email systems on the way, though:
>>
>>      <languageList><iso639Id>swe</iso639Id></languageList>
>>    *</configItem>
>>  </layout>
>> *  <layout>
>>
>> Those bold characters is supposed to be found in this case.
>>
>> I checked the Regular expression check box, of course. One of the things
>> that I tried was the following:
>>
>> </configItem>[:space:]*$[:space:]*</layout>
>>
>> It seems like whenever I put something after the $, it won't find
>> anything.
>> So obviously that's not hte way to go, but what is?
>>
>> J.R.
>>
>>
> I am fairly certain that Regular Expressions (REs) can't be used to search
> across paragraph boundaries. I believe that this is true of pretty much any
> editor that supports REs. (For plain text editors substitute "line ends" for
> "paragraph boundaries".)
>
> So you need a kludge.
>
> 1. Use REs to change *all* the paragraph marks in your text to some
> (preferably short) string that you are sure doesn't occur anywhere in that
> text:
> a) in the Search box enter "$" without the quotes
> b) in the Replace box enter the "magic" string, for example "zxcvb",
> without the quotes.
>
> 2. Now use REs to find your pattern but with the "$" replaced by our magic
> string, so "</configItem>[:space:]*zxcvb[:space:]*</layout>", again without
> the quotes.
>
> 3. Having found the strings you want and done to them whatever you want,
> use REs to change *all* the magic strings back to paragraph marks:
> a) In the Search box enter "zxcvb" - no quotes
> b) In the Replace box enter "\n"
>
> Of course you could do step 2 & 3 for each separate instance by only
> finding the "next" instance of your pattern, working on it and changing its
> magic string back to a paragraph mark:
> a) change all paragraph marks to magic string
> b) do
>      find next pattern including magic string
>      make any changes in this neighbourhood
>      change this magic string to a paragraph mark
>  until done
>
> The problem becomes *much* more complicated if the two parts of your
> pattern can be separated by multiple lines each of which might contain text;
> I haven't tried to solve that problem because you didn't pose it ;-) I'm not
> at all sure that I can :-(
>
> --
> Harold Fuchs
> London, England
> Please reply *only* to users@openoffice.org
>
> Thanks, that worked, but it was a bit hard to read when there was text all
over the place.
Actually I solved it myself before reading your answer. Since the text I was
searching was imported from a text file (/usr/share/X11/xkb/rules/evdev.xml)
I found that I could select CR as paragraph break rather than LF, which made
it possible to use \n in the search string.
If there was a wey to search and replace paragraph breaks by line breaks (or
whatever they are called - Shift+Enter) it would be an acceptable solution.
Maybe I should write a bug report about it, asking for this as an
enhancement, being able to seach for paragraph breaks. The following search
string, for instance, was allowed, there would not be a problem (at least
that I can see):
Text On One Line$Text On The Next Line
I don't really know why this isn't allowed. I would actually consider it a
bug.
J.R.

Reply via email to