Quantcast
Channel: MobileRead Forums - Reading and Management
Viewing all articles
Browse latest Browse all 24033

Using search&replace for blank lines.

$
0
0
There's an issue I've run into that I can't understand. It *may* be a bug, but it may be something else.

I am trying to replace blank lines in an document using the Search & Replace function. I did some research in the forums and online and found a function that will work for what I want, with a few minor modifications on my part. I even used the wizard to make sure it was working. The code is as follows:

Code:

<(\w+)\b(?:\s+[\w\-.:]+(?:\s*=\s*(?:"[^"]*"|"[^"]*"|[\w\-.:]+))?)*\s*\/?>\s*<\/\1\s*>
or
<(p[^>]*|span[^>]*)>(\s|&nbsp;|</?\s?br\s?/?>)*</?(p|span)>

When I have it input, and then do a 'test'

The code it should be replace is:
Code:

<p class="calibre5"> </p>
or
<p class="calibre5"></p>
or
<p class="calibre5"><span class="calibre4"> </span></p>

They both work and find numerous matches in the particular document I'm looking at. The first one caught metadata tags, so I abandoned it for the second, just throwing it in there for thoughts.

Of note, just in case, Heuristic Processing is *not* on. Using Heuristic Processing For the first 2 examples, it works fine. However, if there's a span tag (like the third example) then it doesn't strip out the 'blank' line.

Anyway, the regex should get rid of all of the above. In the case of the last one, it should, at minimum remove the span tag and then I could rerun it, or set a second scan to remove the empty P tag. (I've tried it both ways).

The replace doesn't seem to work, at all. Despite the fact that it matches them when tested, when I look at the code of the new epub file made, there's no change with the tag they all remain the same. Is there something I'm doing wrong? If needed I can provide an example epub. It was initially downloaded with Fanficfare, and it has already been converted, epub (to) epub once, that's why it has the calibre tags.

I've made a test epub by stripping it down to almost nothing in the chapters just enough to test the regex. I can provide it, if needed.

Viewing all articles
Browse latest Browse all 24033

Trending Articles