![]() |
#1 |
Enthusiast
![]() Posts: 37
Karma: 10
Join Date: Jan 2011
Device: Kobo 1
|
Regex problem
I hope someone can help me with a Regex problem.
I have a book without any spaces between some sentences. Sentence one.Sentence two. I would like it to be; Sentence one. Sentence two. I have been using find: ([a-z]\.[A-Z]) which seems to find the Sentences without the space OK. I did a count and 256 were found. But for the life of me I can't seem to get a Replace code. I am using Sigil to do the work. Does any of you learned folks have a suggestion? Thanking you, John P. Last edited by John2011; 01-19-2014 at 04:42 AM. |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
find
([a-z])\.([A-Z]) replace \1. \2 |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
But you will have to do the same thing for exclamation points and question marks and the above inside of quotation marks. Be sure to save a copy before these operations since you can't go back in Sigil.
|
![]() |
![]() |
![]() |
#4 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,014
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:
Remember.you want 2 pieces so you can put them back with inserts. [\.\!\?] could replace the \. to do this in one pass instead of the 3 , the more beginner safe way suggested by mrmikel BTW you may have cases where there are quotation marks (straight or curly) : ".A a."A |
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
arguably all you need to detect is a punctuation mark which is then followed by a capital letter, with no space inbetween.
so find \.(A-Z]) replace with . \1 & repeat for other punctuation but then you can have issues with valid structures like U.S.A. or Mr.Smith ( should Mr. be followed by a space, or not ? ) it can be better to just go find a better source! |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Enthusiast
![]() Posts: 37
Karma: 10
Join Date: Jan 2011
Device: Kobo 1
|
Thank you all for your help.
I see now why I could not get the F&R to do what I wanted. I missed out two ) ( in the find. I will get my head around Regex one day. (I hope). TheDucks; your were correct, there were a couple of ".As I never thought of them until I read your reply. I did have a back up copy just in case. I have been caught in the past. Thank you all again. John P. |
![]() |
![]() |
![]() |
#7 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,014
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:
I have been pushing bits around for quite a few years now and I still have not seen them all and have to frequently reach for my backup ![]() ![]() Think patterns ![]() No exact examples: You fix pattern A The original Pattern A includes Pattern B, but because you fixed A first, the new B is no longer unique (matches other text that should not be changed) |
|
![]() |
![]() |
![]() |
#8 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)
|
You may want to use calibre's Edit Book feature, instead of Sigil. calibre has the ability to undo global actions, like regex replace all.
![]() Sigil does not. ![]() Shortcut key while in calibre is "T". If the book isn't in calibre, you can also use the standalone executable ebook-edit.exe |
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
But Calibre Edit Book still misses some functionality from Sigil that is much used by me. It has some pro's, but also definitely some con's for me at the moment. Considering the speed with which things are developed by Kovid I expect them to be solved soon, but so far... It is not that hard to press the save button first.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regex Problem / Line that does't end with .</p> | mcam77 | Sigil | 6 | 03-25-2013 06:38 PM |
Regex problem: Trying to replace surrounding text without effecting the middle | ghostyjack | Workshop | 3 | 10-09-2012 04:26 PM |
Regex F&R problem? | Jabby | Sigil | 6 | 06-12-2012 04:18 AM |
epub to epub conversion problem with regex spanning multiple input files | ctop | Conversion | 2 | 02-12-2012 01:56 AM |
Regex Problem | huebi | Sigil | 3 | 05-10-2011 04:32 AM |