![]() |
#1 |
Junior Member
![]() 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. ![]() |
![]() |
![]() |
![]() |
#2 |
Created Sigil, FlightCrew
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
Are you performing the search in Book View or Code View? You can't manipulate tags in Book View with search.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() 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? |
![]() |
![]() |
![]() |
#4 |
Created Sigil, FlightCrew
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
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".
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Created Sigil, FlightCrew
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
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. |
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Feb 2010
Device: none
|
Done.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regular Expression Help | Azhad | Calibre | 86 | 09-27-2011 02:37 PM |
Regular Expression Help | smartmart | Calibre | 5 | 10-17-2010 05:19 AM |
Need Help Creating a Regular Expression | Worm | Calibre | 9 | 08-18-2010 01:20 PM |
Help with the regular expression | Dysonco | Calibre | 9 | 03-22-2010 10:45 PM |
I don't know how to use wilcards and regular expression.... | superanima | Sigil | 4 | 02-21-2010 09:42 AM |