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 08-11-2012, 09:44 AM   #121
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,825
Karma: 4525859
Join Date: Dec 2010
Device: Kindle 3, PW2
A quick and dirty solution would be:

Find: (chapter) ([[:lower:]]+)
Replace: \u\1 \u\2

This requires Sigil 0.5.3 (or higher).

Last edited by Doitsu; 08-11-2012 at 09:56 AM.
Doitsu is offline   Reply With Quote
Old 08-11-2012, 09:03 PM   #122
Gunnerp245
Gadget Freak
Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.
 
Gunnerp245's Avatar
 
Posts: 1,107
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: Sony 700; Entourage Edge, Kindle 3, Pocket Edge
Red face

Quote:
Originally Posted by Gunnerp245 View Post
I would like to change the capitalization a particular phrase across a book e.g. chapter one to Chapter One. I can detect the instances using (\D+) (\D+) and know the replacement would be \1 \2, but not how to change the capitalization.
Quote:
Originally Posted by Doitsu View Post
A quick and dirty solution would be:
Find: (chapter) ([[:lower:]]+)
Replace: \u\1 \u\2
This requires Sigil 0.5.3 (or higher).
@Doitsu - Left out key information initially, I am attempting this is calibre 'search and replace'..
Gunnerp245 is online now   Reply With Quote
 
Enthusiast
Old 08-12-2012, 02:35 AM   #123
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,825
Karma: 4525859
Join Date: Dec 2010
Device: Kindle 3, PW2
Quote:
Originally Posted by Gunnerp245 View Post
@Doitsu - Left out key information initially, I am attempting this is calibre 'search and replace'..
Starting with version 0.5.3, Sigil uses Perl compatible regular expressions (PCRE) including the \u operator (which capitalizes the first letter of a string).
AFAIK, Calibre uses the Python regular expression library, which doesn't support the \u operator.
The expressions that I suggested will work in Sigl or any text editor with PCRE support.
Is there any particular reason why want to use Calibre to replace the text?
Doitsu is offline   Reply With Quote
Old 08-12-2012, 03:40 AM   #124
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 5,902
Karma: 4269879
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Doitsu View Post
Is there any particular reason why want to use Calibre to replace the text?
And is there any particular reason why you ask a Calibre question in the Sigil forum?
Jellby is offline   Reply With Quote
Old 08-12-2012, 09:51 AM   #125
Gunnerp245
Gadget Freak
Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.Gunnerp245 ought to be getting tired of karma fortunes by now.
 
Gunnerp245's Avatar
 
Posts: 1,107
Karma: 1043832
Join Date: Nov 2007
Location: US
Device: Sony 700; Entourage Edge, Kindle 3, Pocket Edge
@Doitsu/Jellby

I was reading through the regex sticky and posted my question before realizing which software forum I was in. I have been able to glean very helpful information. Though the other forum has a regex sticky it does not seem as detailed as this one.

I have moved my query here.

Last edited by Gunnerp245; 08-12-2012 at 10:29 AM.
Gunnerp245 is online now   Reply With Quote
Old 08-23-2012, 09:55 AM   #126
Greygor
Junior Member
Greygor began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2012
Device: Samsung Tab 2 GT-P3110
I hate my first post to be a question rather than an answer but needs must when the devil drives.

I have an epub where speech quotes are missing from the start of the line

e.g.

Quote:
<span class="bold calibre4">The gets one," ff 11
So my first task was finding an expression that would find lines where this occurs.

This seems to work (I know there are cases where it fail, but I'm just finding and not auto-fixing)

Quote:
"\>[^"](\w*\W*)*"
However when I try it in Sigil it completely fails.

Is there something special about Sigil's regex that I'm overlooking?

Many thanks in advance
Greygor is offline   Reply With Quote
Old 08-23-2012, 12:11 PM   #127
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,825
Karma: 4525859
Join Date: Dec 2010
Device: Kindle 3, PW2
IMHO, the problem is \w*\W*, which matches a sequence of 0 or more word characters followed by 0 or more non-word characters. I.e., it will at most match one word plus a space or punctuation character. Try .*? instead:

Code:
"\>[^"](.*?)"
Doitsu is offline   Reply With Quote
Old 08-23-2012, 12:22 PM   #128
Greygor
Junior Member
Greygor began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2012
Device: Samsung Tab 2 GT-P3110
Quote:
Originally Posted by Doitsu View Post
IMHO, the problem is \w*\W*, which matches a sequence of 0 or more word characters followed by 0 or more non-word characters. I.e., it will at most match one word plus a space or punctuation character. Try .*? instead:

Code:
"\>[^"](.*?)"
Hi thanks for the response.

Outside of Sigil the regex that I was using worked fine which is what I'm finding odd.

Using
Quote:
"\>[^"](.*?)"
lets me find lots of
Quote:
"><span class="
but unfortunately that's not quite right, but at least it finds something in Sigil which mine doesn't

Need to think about this, I'm missing something really obvious
Greygor is offline   Reply With Quote
Old 08-23-2012, 12:50 PM   #129
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 8,657
Karma: 38766103
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Greygor View Post
Outside of Sigil the regex that I was using worked fine which is what I'm finding odd.
Not really that odd. There are several different regex engines that all have subtle differences. So the questions would be: what application are you using where your original regex does succeed? And what version of Sigil are you using where it doesn't succeed?
DiapDealer is offline   Reply With Quote
Old 09-25-2012, 09:01 AM   #130
paulfiera
Addict
paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.
 
paulfiera's Avatar
 
Posts: 336
Karma: 3102
Join Date: Dec 2010
Location: EU
Device: iPad, Kobo Glo
Strange issue

Most surely, I'm not understanding this the right way.

I'm cleaning up some epubs and have noticed that some of them have anchor tags with a class and an id but without any hyperlink. Some epubs have several hundred in between the text.

So I'm using this regex to find anchor links with nothing inside them

Quote:
<a class="(.*?)" id="(.*?)"></a>
The problem is that it also finds these tags with spans and even text inside.

I would like to be able to restrict the findings to only this situation.

Many thanks!
paulfiera is offline   Reply With Quote
Old 09-25-2012, 09:41 AM   #131
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,825
Karma: 4525859
Join Date: Dec 2010
Device: Kindle 3, PW2
Quote:
Originally Posted by paulfiera View Post
The problem is that it also finds these tags with spans and even text inside.
Your regex looks fine to me. Can you post some specific examples of unwanted html tags matched by your regex and the Sigil version that you're using?
Doitsu is offline   Reply With Quote
Old 09-25-2012, 09:47 AM   #132
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 8,657
Karma: 38766103
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm not certain why that expression would match instances with spans or text inside the anchor tags. It shouldn't really.

You might try:
Code:
<a class="([^>]*?)" id="([^>]*?)"></a>
instead ... just to check.

But I can't get your expression to misbehave, really. It seems to do (for me anyway) what you've intended it to do. Can you give any examples of code it's matched that you don't think it should match?
DiapDealer is offline   Reply With Quote
Old 09-25-2012, 09:48 AM   #133
theducks
Grand Sorcerer
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: 14,096
Karma: 5468860
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by paulfiera View Post
Most surely, I'm not understanding this the right way.

I'm cleaning up some epubs and have noticed that some of them have anchor tags with a class and an id but without any hyperlink. Some epubs have several hundred in between the text.

So I'm using this regex to find anchor links with nothing inside them



The problem is that it also finds these tags with spans and even text inside.

I would like to be able to restrict the findings to only this situation.

Many thanks!
Your REGEX is fine as Doitsu said. It is also overly broad (second term) ;)
which is why it is matching </span></a>

if your id has an ending numbers use that to narrow the scope:(.+?\d+)"></a>
theducks is offline   Reply With Quote
Old 09-25-2012, 10:40 AM   #134
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 5,902
Karma: 4269879
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by DiapDealer View Post
But I can't get your expression to misbehave, really. It seems to do (for me anyway) what you've intended it to do. Can you give any examples of code it's matched that you don't think it should match?
<a class="whatever" href="#here">this is a link</a> <a class="other" id="something"></a>

The whole red part would be matched by the first (.*?), right?
Jellby is offline   Reply With Quote
Old 09-25-2012, 10:59 AM   #135
paulfiera
Addict
paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.paulfiera could sell banana peel slippers to a Deveel.
 
paulfiera's Avatar
 
Posts: 336
Karma: 3102
Join Date: Dec 2010
Location: EU
Device: iPad, Kobo Glo
Thanks, Doitsu and DiapDealer

This is from Clive Barker's Imajica

Using

Quote:
<a class="(.*?)" id="(.*?)"></a>
and clicking on Count All, it finds 18 matches.

Clicking on Find, the first match is this one:

Quote:
<a class="calibre16" href="../Text/Imajica_split_211.html#filepos2489718" id="filepos69564"><span class="calibre17">William</span></a>—and they had only argued once, but it had been a telling exchange. She’d accused him of always looking at other women; looking, looking, as though for the next conquest. Perhaps because he didn’t care for her too much, he’d replied honestly and told her she was right. He was stupid for her sex. Sickened in their absence, blissful in their company: love’s fool. She’d replied that while his obsession might be healthier than her husband’s—which was money and its manipulation—his behavior was still neurotic. Why this endless hunt? she’d asked him. He’d answered with some folderol about seeking the idealwoman, but he’d known the truth even as he was spinning her this tosh, and it was a bitter thing. Too bitter, in fact, to be put on his tongue. In essence, it came down to <a class="calibre22"></a>
Clicking on Find again, it matches this one:


Quote:
<a class="calibre16" href="../Text/Imajica_split_199.html#filepos2416389" id="filepos73127"><span class="calibre17">Gloriana</span></a>, one of his five cats, escaped in search of a mate. “Too slow, sweetie!” he told her. She yowled at him in complaint. “I keep her fat so she’s slow,” he said. “And I don’t feel so piggy myself.”<a class="calibre22"></a>
This is on Sigil 0.5.3

Strange.
paulfiera 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
Examples of Subgroups emonti8384 Lounge 32 02-26-2011 06:00 PM
Accessories Pen examples Gunnerp245 enTourage Archive 15 02-21-2011 03:23 PM
Stylesheet examples? Skitzman69 Sigil 15 09-24-2010 08:24 PM
Examples kafkaesque1978 iRiver Story 1 07-26-2010 03:49 PM
Looking for examples of typos in eBooks Tonycole General Discussions 1 05-05-2010 04:23 AM


All times are GMT -4. The time now is 06:21 AM.


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