12-06-2014, 10:24 AM | #1 |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
Empty space in Paragraph
Sometimes I see writers do this(after conversion to epub):
Code:
<p class="normal">Lorem ipsum dolor sit amet </p> Is there any script / regex to get rid of those? |
12-06-2014, 10:27 AM | #2 |
Resident Curmudgeon
Posts: 76,977
Karma: 138588794
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
All you need do is search for a space in front of the </p> and replace with </p>. And just keep doing that over and over until there is no more space in front of </p>.
|
Advert | |
|
12-06-2014, 11:11 AM | #3 |
Grand Sorcerer
Posts: 12,904
Karma: 76440364
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
Why not just search for multiple spaces </p>, in other words [ ]*</p> or even [ ]*</ to look for all occurences of spaces directly before the closing of any tag?
|
12-06-2014, 11:45 AM | #4 | |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
Quote:
@JSWolf, nice new profile pic :P Thanks guys. |
|
12-06-2014, 01:26 PM | #5 |
Zealot
Posts: 119
Karma: 64428
Join Date: Aug 2011
Device: none
|
The only gotcha is that if you use a space character inside square brackets, it has to be the last character.
|
Advert | |
|
12-06-2014, 10:19 PM | #6 |
Well trained by Cats
Posts: 30,506
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Why not \s{1,}</p>
|
12-07-2014, 04:32 AM | #7 |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
|
12-07-2014, 06:29 AM | #8 |
Grand Sorcerer
Posts: 5,647
Karma: 23456789
Join Date: Dec 2010
Device: Kindle PW2
|
|
12-07-2014, 07:15 AM | #9 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
None of those catches
Code:
(\s+|( )*)</p> Last edited by rubeus; 12-07-2014 at 07:16 AM. Reason: mask smileys |
12-27-2014, 08:10 AM | #10 |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
This \s{1,} method worked well.
Could you explain the different parts of the that expression? \s = search for a string {1,} = placeholder for empty space Is this correct? could you elaborate on what other searches you could possibly do using these operators/placeholders? e.g. what would {2,} mean? what would \n or \r mean? Thanks |
12-27-2014, 08:21 AM | #11 | |
Grand Sorcerer
Posts: 5,647
Karma: 23456789
Join Date: Dec 2010
Device: Kindle PW2
|
@odeta: For a short Regex summary, see this site. BTW, there are slightly different Regex flavors; Sigil uses PCRE (=Perl-compatible regular Expressions.)
Quote:
{1,} = number of preceding characters to be found (in this case at least one) \n = line-break \r = carriage-return I used the + operator, because it's shorthand for {1,}. |
|
12-27-2014, 10:18 AM | #12 |
Curmudgeon
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Empty line between paragraph in epub on Pocketbook 626 | nickie_twisp | Calibre | 2 | 11-30-2014 01:59 PM |
How detelete empty paragraph? | cyttorak | Recipes | 2 | 11-27-2014 03:41 AM |
Space before paragraph not coming through in epub | steve2112 | ePub | 15 | 06-06-2012 08:26 AM |
Paragraph/line space - "n" added | NormalJoe | Conversion | 6 | 01-25-2011 12:28 PM |
How much empty space I should leave on SD card for 505? | alxwang | Sony Reader | 7 | 05-13-2009 11:31 PM |