Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 02-17-2010, 06:31 AM   #1
hydrolith
Junior Member
hydrolith began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Feb 2010
Device: none
Find/Replace with regular expression

I'm new to Sigil and to regex. I have a massive epub file I'm trying to clean up, and I've noticed that many of the paragraphs in the PDF were not recognised when it was converted to epub. The result is that many paragraphs begin straight after the period of the preceding sentence.

For example:
"This is an entire paragraph.This is another paragraph.And another one."

I'd like to be able to insert paragraph tags between these, so I don't have to do it by hand. I've managed to construct the following Find/Replace search:

FIND
\.(?=\S)

REPLACE
.</p> <p>

The idea is to search for periods followed immediately by non-space characters, but not including the non-space character in the replace, and then replacing the period with a period and paragraph tags.

i.e. "This is an entire paragraph.</p>
<p>This is another paragraph.</p>
<p>And another one."

My problem is that the search works just as it should, but the replace doesn't. It just skips to the next period without changing anything. In fact, nothing entered in the replace window (e.g. "fkgfgjflkjgl") is inserted.

Any help most appreciated. If there's another way to achieve my goal of inserting paragraph tags, that's fine too. The manual option is giving me RSI.
hydrolith is offline   Reply With Quote
Old 02-17-2010, 08:26 AM   #2
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,978
Karma: 350515
Join Date: Feb 2008
Device: Sony Reader PRS 505
Are you performing the search in Book View or Code View? You can't manipulate tags in Book View with search.
Valloric is offline   Reply With Quote
Old 02-17-2010, 10:42 AM   #3
hydrolith
Junior Member
hydrolith began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Feb 2010
Device: none
Thanks for the response. I'm searching in Code View. Other code find/replace searches work fine.

I downloaded a text editor (TextMate) and it had the very same problem with this search (finding but not replacing), so it doesn't appear to be a Sigil-specific issue.

The search:

FIND
\.

REPLACE
.</p> <p>

...works fine in both Sigil and TextMate, so the "(?=\S)" appears to be the problem. I thought perhaps I had the wrong regex code. Is there any other way to add the paragraph tags?
hydrolith is offline   Reply With Quote
Old 02-17-2010, 11:51 AM   #4
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,978
Karma: 350515
Join Date: Feb 2008
Device: Sony Reader PRS 505
I just tried the search/replace strings you posted in your first post and they work for me. Make sure you're using "Regular expression" for "Search mode".
Valloric is offline   Reply With Quote
Old 02-18-2010, 04:58 AM   #5
hydrolith
Junior Member
hydrolith began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Feb 2010
Device: none
Hmmm. Weird. I've been using "Regular expression" for search mode, so it isn't that.

I've decided to just copy and paste the necessary sections from the latex files and transform those into html. The Sigil search finds the paragraph indent and extra line in the latex, and I can replace with paragraph tags that way no problem. I'll need to do a few other replaces as well, but it shouldn't take too long.

Thanks for checking it out for me.
hydrolith is offline   Reply With Quote
Old 02-18-2010, 12:57 PM   #6
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,978
Karma: 350515
Join Date: Feb 2008
Device: Sony Reader PRS 505
I just got this to replicate. When you use "Replace All", it works. But when you use "Replace", it jumps from one to the next without replacing.

It's a bug. Please report it on the tracker so it doesn't get lost. Add a link to this thread too.
Valloric is offline   Reply With Quote
Old 03-01-2010, 09:42 PM   #7
hydrolith
Junior Member
hydrolith began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Feb 2010
Device: none
Done.
hydrolith is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Azhad Calibre 86 09-27-2011 03:37 PM
Regular Expression Help smartmart Calibre 5 10-17-2010 06:19 AM
Need Help Creating a Regular Expression Worm Calibre 9 08-18-2010 02:20 PM
Help with the regular expression Dysonco Calibre 9 03-22-2010 11:45 PM
I don't know how to use wilcards and regular expression.... superanima Sigil 4 02-21-2010 10:42 AM


All times are GMT -4. The time now is 09:00 PM.


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