Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 01-26-2015, 10:03 PM   #1
mikapanja
Perfectionist
mikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
Removing double space

I have a text riddled with double spaces between words. I'm using \w__\w to find the instances and it works OK, but I don't know what to put in the replace field.

For example, I'd like to replace "was__not" with "was not" using a regular expression.

Anyone?
mikapanja is offline   Reply With Quote
Old 01-26-2015, 10:24 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Find: \s{2,}
Replace: <--This is an invisible space.

But then you have to prettify everything.

This is one of those things that exclsively affects coder typography senses something I don't fault you for.

I would like this to be in Beautify, but Kovid nixed that because crazy people might be using CSS to render consecutive whitespace.

Last edited by eschwartz; 01-26-2015 at 10:27 PM.
eschwartz is offline   Reply With Quote
Advert
Old 01-26-2015, 10:26 PM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Or:

Find: (\w) (\w)
Replace: \1 \2
davidfor is offline   Reply With Quote
Old 01-27-2015, 02:01 AM   #4
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Why would you want to replace that? A double space would be rendered as one anyway. That is, unless at least one of the spaces is not a real space, but for example a non-breakable space. In that case I am not sure the proposed regex would catch those.
Toxaris is offline   Reply With Quote
Old 01-27-2015, 10:56 AM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Code typography nuts, like I said.
eschwartz is offline   Reply With Quote
Advert
Old 01-27-2015, 11:23 AM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by eschwartz View Post
Code typography nuts, like I said.
Enough of them would affect (increase) file size.

My 1958 typing class: "2 spaces are required at the end of any sentence" Maybe the originator has not done the update on their style guide in a loooong time
theducks is offline   Reply With Quote
Old 01-27-2015, 11:30 AM   #7
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
The difference should be largely offset by compression?
eschwartz is offline   Reply With Quote
Old 01-27-2015, 12:50 PM   #8
mikapanja
Perfectionist
mikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
Quote:
Originally Posted by davidfor View Post
Or:

Find: (\w) (\w)
Replace: \1 \2
Well, this is odd.

That's exactly what I'd tried before asking the question. RegEx Mode ON. All spaces in place. It didn't work.

Now it does

Anyway, davidfor, thanks!

Quote:
Originally Posted by Toxaris View Post
Why would you want to replace that? A double space would be rendered as one anyway.
Quote:
Originally Posted by eschwartz View Post
Code typography nuts, like I said.
Yes, exactly, and proudly so

I like the code to be clean, too, not only the visible text. I see no harm in that.
mikapanja is offline   Reply With Quote
Old 02-02-2015, 12:05 PM   #9
LadyKate
Fanatic
LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.
 
Posts: 515
Karma: 1470724
Join Date: Jul 2013
Location: Quebec CA
Device: android 4 (samsung tablet and asus tablet)
When something bugs me enough I get into the code and painstakingly change every instance of the problem.

One problem I see with

Find: (\w) (\w)
Replace: \1 \2
is that it appears to me to be finding two white spaces and replacing both. Could one of the problems be if the white space is a tab?

When you look at it in edit are you seeing two spaces? or a &nbsp;? I find that the more specific you are the easier it is to correct.

One last thought... is the css justifying the lines causing the appearance of larger spaces?
LadyKate is offline   Reply With Quote
Old 02-02-2015, 02:08 PM   #10
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by LadyKate View Post
When something bugs me enough I get into the code and painstakingly change every instance of the problem.

One problem I see with

Find: (\w) (\w)
Replace: \1 \2
is that it appears to me to be finding two white spaces and replacing both. Could one of the problems be if the white space is a tab?

When you look at it in edit are you seeing two spaces? or a &nbsp;? I find that the more specific you are the easier it is to correct.

One last thought... is the css justifying the lines causing the appearance of larger spaces?
this gets space or tab

Code:
(\w)[[:space:]]{2,}(\w)
theducks is offline   Reply With Quote
Old 02-02-2015, 02:55 PM   #11
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
That would be why post #2 was my suggestion to use "\s{2,}"

Or for that matter, "(\s|&nbsp;){2,}"
eschwartz is offline   Reply With Quote
Old 02-02-2015, 03:02 PM   #12
mikapanja
Perfectionist
mikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermikapanja can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
Quote:
Originally Posted by LadyKate View Post
One problem I see with

Find: (\w) (\w)
Replace: \1 \2

is that it appears to me to be finding two white spaces and replacing both. Could one of the problems be if the white space is a tab?

When you look at it in edit are you seeing two spaces? or a &nbsp;?
The book I was editing had regular spaces doubled, no non-breaking spaces or tabs.

Quote:
Originally Posted by LadyKate View Post
One last thought... is the css justifying the lines causing the appearance of larger spaces?
Well, yes, it does so here and there, depending on the letter count in a row. But upon opening a book in the editor, one can easily determine if it is just an appearance or a real problem.
mikapanja is offline   Reply With Quote
Old 02-11-2015, 01:40 PM   #13
Deina97
Member
Deina97 began at the beginning.
 
Deina97's Avatar
 
Posts: 17
Karma: 10
Join Date: Nov 2014
Device: Samsung Note
I search for (spacebar)(spacebar)+ in Regex

You could also use (spacebar){2,} ( (spacebar) means tap the space bar, don't type the word in! )

Either way means you are looking for two or more spaces.

***

Another Regex that I use all the time (usually just before the one above) is
Search: \n
replace: (spacebar)

That removes ALL line feeds & replaces them with spaces.

After I've done the two operations above, I Beautify all files, which puts in only the necessary line feeds.
Deina97 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get a double space between paragraphs? ficbot Sigil 7 07-17-2013 09:12 PM
Want double-space between sentences GrannyGrump Sigil 11 05-28-2011 10:47 AM
Students with a .edu address can get double referral space on Dropbox cheyennedonna enTourage Archive 5 01-12-2011 09:59 AM
What is the double space trick? Jabby Calibre 18 08-29-2010 09:48 PM
Double chapter break when removing first image tochill Calibre 0 03-04-2010 07:41 PM


All times are GMT -4. The time now is 06:58 PM.


MobileRead.com is a privately owned, operated and funded community.